aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators/active_record/model
Commit message (Collapse)AuthorAgeFilesLines
* move `db_migrate_path` method to `Migration` moduleyuuji.yaginuma2017-01-221-8/+0
| | | | | Since `Migration` module is included in both `MigrationGenerator` and `ModelGenerator`, no need to define a common method for each class.
* Generate migrations at path set by `config.paths["db/migrate"]`Kevin Glowacz2017-01-161-1/+9
|
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Revert "Merge pull request #27550 from ↵Rafael Mendonça França2017-01-031-1/+1
| | | | | | | | | mtsmfm/fix-generator-command-for-nested-rails-engine" This reverts commit 1e969bfb98b88799e2c759fce25a1d8cf00d7ce7, reversing changes made to a5041f267ded119c2d00b8786c2f2c1e3f93c8a1. Reason: It breaks the public API
* Fix generator command for nested (namespaced) rails engineFumiaki MATSUSHIMA2017-01-031-1/+1
| | | | | | | | | | | | | If we create nested (namespaced) rails engine such like bukkits-admin, `bin/rails g scaffold User name:string age:integer` will create `bukkits-admin/app/controllers/bukkits/users_controller.rb` but it should create `bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`. In #6643, we changed `namespaced_path` as root path because we supposed application_controller is always in root but nested rails engine's application_controller will not.
* No need `:doc:` for `:nodoc:` classes [ci skip]Ryuta Kamizono2016-12-251-5/+5
| | | | | | Follow up to 5b14129d8d4ad302b4e11df6bd5c7891b75f393c. http://edgeapi.rubyonrails.org/classes/ActiveRecord/Attribute.html
* Privatize unneededly protected methods in Active RecordAkira Matsuda2016-12-241-6/+6
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-6/+6
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Always genererate models with ApplicationRecord parentGenadi Samokovarov2016-04-281-11/+3
| | | | | | | | | | | | | | | | Currently, if we generate a model while `app/model/application_record.rb` isn't present, we'll end up with a model with an `ActiveRecord::Base` parent _and_ a newly generated `app/models/application_record.rb`. While the behavior for choosing an `ActiveRecord::Base` was chosen for an easier migration math to 5.0, generating the `app/model/application_record.rb` file kinda contradicts with it. In any case, I think we should decide on a behavior and stick to it. Here, I'm changing the generated parent to always be `ApplicationRecord` and to always create `app/model/application_record.rb` if it doesn't exist.
* correctly check `ApplicationRecord` is exist in moutable engineyuuji.yaginuma2016-02-252-11/+17
| | | | Follow up to 1813b29fc7632959800252f36e4b2e6ed4ac7266
* Add notes for future selvesJon Moss2016-02-221-0/+1
| | | | | | | Once RubyGems 2.5.0 is required, then the duplicated files can be removed, and symlinks can be used instead. [ci skip]
* Generate ApplicationRecord if it does not already existJon Moss2016-02-222-0/+11
|
* correctly presence check of `application_record.rb` in pluginyuuji.yaginuma2016-01-021-1/+7
|
* Make sure File.exist? run in the root of the applicationRafael Mendonça França2015-12-161-1/+5
|
* Do not define attributes_with_index as a Thor taskRafael Mendonça França2015-12-161-4/+4
| | | | | All public methods are tasks, so we need to move it to protected visibility.
* Remove dead codeRafael Mendonça França2015-12-161-4/+0
|
* Introduce ApplicationRecord, an Active Record layer supertypeGenadi Samokovarov2015-12-161-1/+8
| | | | | | | | | | | | | | | | It's pretty common for folks to monkey patch `ActiveRecord::Base` to work around an issue or introduce extra functionality. Instead of shoving even more stuff in `ActiveRecord::Base`, `ApplicationRecord` can hold all those custom work the apps may need. Now, we don't wanna encourage all of the application models to inherit from `ActiveRecord::Base`, but we can encourage all the models that do, to inherit from `ApplicationRecord`. Newly generated applications have `app/models/application_record.rb` present by default. The model generators are smart enough to recognize that newly generated models have to inherit from `ApplicationRecord`, but only if it's present.
* Stop aligning the argumentsRafael Mendonça França2015-10-231-4/+4
|
* Use thor class_option to make the primary_key_type option workRafael Mendonça França2015-10-231-2/+1
| | | | Also move the method to the right class
* Add Secure Token Generatorrobertomiranda2015-01-111-0/+3
|
* Add a `required` option to the model generatorSean Griffin2014-08-081-1/+1
| | | | | | | | | | | Syntax was chosen to follow the passing of multiple options to decimal/numeric types. Curly braces, and allowing any of `,`, `.`, or `-` to be used as a separator to avoid the need for shell quoting. (I'm intending to expand this to all columns, but that's another PR. The `required` option will cause 2 things to change. `required: true` will be added to the association. `null: false` will be added to the column in the migration.
* copy edits[ci skip]Vijay Dev2013-05-191-1/+1
|
* Added documentation for model migration generationaditya-kapoor2013-05-141-0/+4
|
* Add support for generate scaffold password:digestSam Ruby2013-03-131-1/+4
| | | | | | | | | | * adds password_digest attribute to the migration * adds has_secure_password to the model * adds password and password_confirmation password_fields to _form.html * omits password entirely from index.html and show.html * adds password and password_confirmation to the controller * adds unencrypted password and password_confirmation to the controller test * adds encrypted password_digest to the fixture
* Support creating a table migration generatorSammy Larbi2013-03-012-16/+1
| | | | | | | | | | | | | | | | Sometimes you want to create a table without an associated model and test, which is also not a join table. With this commit, you can now do that. Example: rails g migration create_posts title:string or rails g migration CreatePosts title:string This commit also moves the template the model generator uses for the migration to the migration templates folder, as it seems a more sensible place for it now that it is shared code.
* nodoc AR::Generators [ci skip]Francesco Rodriguez2012-10-201-2/+2
|
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-5/+0
|
* Fixed generating namespaced table_name_prefix in enginesWojciech Wnętrzak2012-07-061-1/+1
|
* Add polymorphic option to model generatorAleksey Magusev2012-06-271-1/+1
| | | | | | | | | | For instance, $ rails g model Product supplier:references{polymorphic} generate model with `belongs_to :supplier, polymorphic: true` association and appropriate migration. Also fix model_generator_test.rb#L196 and #L201
* Automatically create indexes for references/belongs_to statements in migrations.Joshua Wood2012-04-141-1/+2
|
* Whitelist all attribute assignment by default.Michael Koziarski2012-03-052-0/+9
| | | | Change the default for newly generated applications to whitelist all attribute assignment. Also update the generated model classes so users are reminded of the importance of attr_accessible.
* Tidy up migration types.José Valim2011-12-242-8/+7
|
* added ability to specify from cli when generating a model/migration whether ↵Dmitrii Samoilov2011-12-242-3/+6
| | | | particular property should be an index like this 'rails g model person name:string:index profile:string'
* for => each in model migration templateGuillermo Iguaran2011-05-201-1/+1
|
* Delete blank lines in migration generatorSantiago Pastorino2011-02-021-3/+2
|
* Configurable generation of add_index for references columnsMichał Łomnicki2011-02-012-0/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Use Rails 3.1 `change` method in model generatorPrem Sichanugrist2011-01-041-5/+1
|
* Generate add_index by default when giving type belongs_to or referencesSantiago Pastorino2010-12-161-0/+4
|
* updating generatorsAaron Patterson2010-11-171-2/+2
|
* Generators fix: properly check if module should be created when creating a ↵Piotr Sarnacki2010-09-251-1/+1
| | | | | | namespaced model Signed-off-by: José Valim <jose.valim@gmail.com>
* Refactor namespaced generators to use module_namespacing block helperPiotr Sarnacki2010-09-243-2/+6
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Generators are not aware of namespace of isolated engines and applicationsPiotr Sarnacki2010-09-241-2/+2
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Patch for Namespace problem in Scaffold. [#4763 state:resolved]Mohammed Siddick.E2010-06-231-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Generate module file for namespaced models [#4230 state:resolved]Andrew White2010-04-122-0/+10
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Load generators from both lib/rails/generators and lib/generators. Using the ↵José Valim2010-03-233-0/+54
former since it's less obstrusive.