aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails/generators
Commit message (Collapse)AuthorAgeFilesLines
* Add three new rubocop rulesRafael Mendonça França2016-08-161-1/+1
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-27/+27
|
* modernizes hash syntax in activerecordXavier Noria2016-08-062-2/+2
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-064-14/+14
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* adds missing requiresXavier Noria2016-07-241-0/+1
|
* systematic revision of =~ usage in ARXavier Noria2016-07-231-1/+1
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* 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
|
* Added references option to join tablesErnst Rullmann2016-01-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes issue #22960 When creating join tables with the command rails g migration CreateJoinTableShowroomUser showroom:references user:references The migration will use references to create the joins and output: class CreateJoinTableShowroomUser < ActiveRecord::Migration def change create_join_table :showrooms, :users do |t| t.references :showroom, index: true, foreign_key: true t.references :user, index: true, foreign_key: true end end end This allows for proper refrences with indexes and foreign keys to be easily used when adding join tables. Without `:refrences` the normal output is generated: class CreateJoinTableShowroomUser < ActiveRecord::Migration[5.0] def change create_join_table :showrooms, :users do |t| # t.index [:showroom_id, :user_id] # t.index [:user_id, :showroom_id] end end end
* 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.
* Add migration versioning via Migration subclassesMatthew Draper2015-12-152-2/+2
|
* 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-234-10/+10
| | | | Also move the method to the right class
* Move default uuid generation to active_recordJon McCartie2015-10-232-1/+9
|
* Set active_record config for always creating uuids in generatorsJon McCartie2015-10-201-1/+1
|
* [ci skip] Correct grammar, add docs to ActiveRecord migration generatorNick Cox2015-04-281-4/+5
|
* Add Secure Token Generatorrobertomiranda2015-01-113-0/+11
|
* Change the default `null` value for `timestamps` to `false`Rafael Mendonça França2015-01-041-1/+1
|
* Use the new `foreign_key` option on `references` in generatorsSean Griffin2014-12-222-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes `rails g model Post user:references` from def change create_table :posts do |t| t.references :user, index: true end add_foreign_key :posts, :users end to def change create_table :posts do |t| t.references :user, index: true, foreign_key: true end end Changes `rails g migration add_user_to_posts user:references` from def change add_reference :posts, :users, index: true add_foreign_key :posts, :users end to def change add_reference :posts, :users, index: true, foreign_key: true end
* Generators add foreign keys on referencesDerek Prior2014-11-252-0/+9
| | | | | | | | | | | If you run a generator such as: ``` rails generate model accounts supplier:references ``` The resulting migration will now add the corresponding foreign key constraint unless the reference was specified to be polymorphic.
* Merge pull request #16062 from sgrif/sg-required-generatorsRafael Mendonça França2014-08-172-2/+2
|\ | | | | Add a `required` option to the model generator
| * Add a `required` option to the model generatorSean Griffin2014-08-082-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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.
* | Change the default `null` value for timestampsSean Griffin2014-08-121-1/+1
|/ | | | | | | As per discussion, this changes the model generators to specify `null: false` for timestamp columns. A warning is now emitted if `timestamps` is called without a `null` option specified, so we can safely change the behavior when no option is specified in Rails 5.
* Fix Generation of proper migration whenKuldeep Aggarwal2014-03-251-3/+7
| | | | | | | | | | | | ActiveRecord::Base.pluralize_table_names = false. Previously, generation a migration like this: rails g migration add_column_name_to_user name would not generating the correct table name. Fixes #13426.
* Make `.next_migration_number` reusable for third party AR generators.Yves Senn2013-09-302-8/+20
|
* copy edits[ci skip]Vijay Dev2013-05-191-1/+1
|
* Added documentation for model migration generationaditya-kapoor2013-05-141-0/+4
|
* Added documentation for ↵aditya-kapoor2013-05-101-0/+4
| | | | ActiveRecord::Generators::MigrationGenerator.next_migration_number
* Add support for generate scaffold password:digestSam Ruby2013-03-132-1/+8
| | | | | | | | | | * 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-013-3/+10
| | | | | | | | | | | | | | | | 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.
* Migration generators use `change` even for destructive methods [#8267]Marc-Andre Lafortune2012-12-211-16/+4
|
* Remove observers and sweepersRafael Mendonça França2012-11-282-19/+0
| | | | | | | | They was extracted from a plugin. See https://github.com/rails/rails-observers [Rafael Mendonça França + Steve Klabnik]
* nodoc AR::Generators [ci skip]Francesco Rodriguez2012-10-204-10/+10
|
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-5/+0
|
* add mini-validator on creating migrationJan Bernacki2012-09-061-0/+9
| | | | move validation to AR
* Extract ActiveRecord::SessionStore from RailsPrem Sichanugrist2012-08-242-36/+0
| | | | | This functionality will be available from gem `active_record-session_store` instead.
* removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-061-2/+2
| | | | | | | | | | | | | | | | | | | by Active Support) Selecting which key extensions to include in active_support/rails made apparent the systematic usage of Object#in? in the code base. After some discussion in https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d we decided to remove it and use plain Ruby, which seems enough for this particular idiom. In this commit the refactor has been made case by case. Sometimes include? is the natural alternative, others a simple || is the way you actually spell the condition in your head, others a case statement seems more appropriate. I have chosen the one I liked the most in each case.
* load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
|
* Add fkey attributes to `join_table` migration generatorAleksey Magusev2012-07-191-2/+10
|
* Add join table migration generatorAleksey Magusev2012-07-182-6/+27
| | | | | | | | | | | | | For instance, running rails g migration CreateMediaJoinTable artists musics:uniq will create a migration with create_join_table :artists, :musics do |t| # t.index [:artist_id, :music_id] t.index [:music_id, :artist_id], unique: true end
* Add references statements to migration generatorAleksey Magusev2012-07-081-4/+16
| | | | | | | | | | | | | AddXXXToYYY/RemoveXXXFromYYY migrations are produced with references statements, for instance rails g migration AddReferencesToProducts user:references supplier:references{polymorphic} will generate the migration with: add_reference :products, :user, index: true add_reference :products, :supplier, polymorphic: true, index: true
* 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
* Refactor migration generatorOscar Del Ben2012-05-181-6/+3
|