diff options
author | Prathamesh Sonpatki <csonpatki@gmail.com> | 2019-04-15 19:40:38 +0530 |
---|---|---|
committer | Prathamesh Sonpatki <csonpatki@gmail.com> | 2019-04-15 20:27:55 +0530 |
commit | 76c1528c5fd372af080081873b1ba02582c51f25 (patch) | |
tree | 4e3cc7d6cf4c6cd56a1b47eedcc56b59922035b7 /activerecord/lib | |
parent | d1107f4d1e2573948d4941ac44511a0af6241f80 (diff) | |
download | rails-76c1528c5fd372af080081873b1ba02582c51f25.tar.gz rails-76c1528c5fd372af080081873b1ba02582c51f25.tar.bz2 rails-76c1528c5fd372af080081873b1ba02582c51f25.zip |
Remove `required: true` from the model generator template
`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.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt b/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt index c1c03e2762..77b9ea1c86 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt +++ b/activerecord/lib/rails/generators/active_record/model/templates/model.rb.tt @@ -1,7 +1,7 @@ <% module_namespacing do -%> class <%= class_name %> < <%= parent_class_name.classify %> <% attributes.select(&:reference?).each do |attribute| -%> - belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %> + belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %> <% end -%> <% attributes.select(&:rich_text?).each do |attribute| -%> has_rich_text :<%= attribute.name %> |