| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
Also move the method to the right class
|
| |
|
| |
|
| |
|
|
|
|
| |
Fix #18301
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|\
| |
| | |
Add a `required` option to the model generator
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
This is a follow up to #13515. It includes the name given and
the singularized version in the warning message. This will aide the user
to see wether the detected singular was right or not.
|
|
|
|
|
| |
1. Generate model with correct_name.
2. It will help new users to avoid mistakes when tried to create model with wrong name.
|
| |
|
| |
|
|
|
|
| |
attributes
|
| |
|
|
|
|
| |
fixtures
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the default test locations to avoid confusion around the common
testing terms "unit" and "functional".
Add new rake tasks for the new locations, while maintaining backwards
compatibility with the old rake tasks.
New testing locations are as follows:
app/models -> test/models (was test/units)
app/helpers -> test/helpers (was test/units/helpers)
app/controllers -> test/controllers (was test/functional)
app/mailers -> test/mailers (was test/functional)
|
|
|
|
| |
mass_assignment_sanitizers
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
| |
Broken after this 6a054b0038bac288a1f6e45feb5470f4ee492081
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
|
|
|
| |
particular property should be an index like this 'rails g model person name:string:index profile:string'
|
|
|
|
| |
This allows the following: "rails g scaffold Post title body:text author"
|
|
|
|
|
|
| |
this fixes: "warning: ambiguous first argument; put parentheses or even spaces"
because: you need this to tell the parser that you're not calling :/ method (division)
details (Japanese!): http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-dev/42445?42370-43277
|
|
|
|
|
|
| |
[#6375 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
|
|
|
| |
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
|
| |
|
|
|
|
|
|
| |
state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
| |
|
|
|
|
|
|
| |
[#5526 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
|
|
| |
state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
Signed-off-by: José Valim <jose.valim@gmail.com>
|
|
|
|
| |
former since it's less obstrusive.
|
| |
|
|
|
|
| |
rspec:install generator, you need generators/rspec/install_generator in your load path.
|
| |
|
| |
|
|
|
|
| |
This reverts commit a288b74f1c75c6f100de7611a5093a421f1ad6d1.
|
|
|
|
| |
Signed-off-by: Yehuda Katz <wycats@gmail.com>
|
| |
|
|
|
|
|
|
|
|
| |
tests for namespaced model generation.
[#767 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
|
| |
|