aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators/active_record/model
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | We sometimes say "✂️ newline after `private`" in a code review (e.g. https://github.com/rails/rails/pull/18546#discussion_r23188776, https://github.com/rails/rails/pull/34832#discussion_r244847195). Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style `EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059). That cop and enforced style will reduce the our code review cost.
* Remove `required: true` from the model generator templatePrathamesh Sonpatki2019-04-151-1/+1
| | | | | | | | `belongs_to` association have `required: true` by default https://github.com/rails/rails/pull/18937 onwards so we don't need it in the generator template. We still need the code for required in the command line generator as it adds `null: false` in the migration.
* Add attachment and attachments field generatorsChris Oliver2019-03-301-0/+6
|
* Add rich_text field to model generatorsChris Oliver2019-03-281-0/+3
|
* Make aliases of `database` option in generators workyuuji.yaginuma2019-03-201-1/+1
| | | | | | | | | | | Thor automatically adds `-` if aliases do not start with `-`. https://github.com/erikhuda/thor/blob/0879c1773d188902d54f95174f33961ac33111f8/lib/thor/parser/options.rb#L53 But Thor follows a convention of one-dash-one-letter options. So, even if `-` is added to `db`, it does not work. https://github.com/erikhuda/thor/blob/0879c1773d188902d54f95174f33961ac33111f8/lib/thor/parser/options.rb#L4 Follow up #34021.
* Refactor migrations_path command option to databaseGannon McGibbon2018-09-281-1/+1
|
* Add migrations_paths option to model generatorGannon McGibbon2018-09-271-0/+1
|
* Use .tt extension to all the template filesRafael Mendonça França2017-11-132-0/+0
| | | | | | | | Make clear that the files are not to be run for interpreters. Fixes #23847. Fixes #30690. Closes #23878.
* Stop creating ApplicationRecord on model generationLisa Ugray2017-07-242-28/+0
| | | | | | | | | | | | | | When generating models, we created ApplicationRecord in the default location if no file existed there. That was annoying for people who moved it to somewhere else in the autoload path. At this point, the vast majority of apps should have either run the upgrade script or generated a model since upgrading. For those that haven't the error message after generating a new model should be helpful: NameError: uninitialized constant ApplicationRecord To ease friction in that case, this also adds a generator for ApplicationRecord.
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* 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
|