diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-12-16 20:10:30 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-12-16 20:58:58 -0200 |
commit | 3b9120fa52b76fb8591fe1d0db85d1a940e867d0 (patch) | |
tree | 9f7a66f9bd99a31a5b69f2c06b2ff0231d02b4b0 /activerecord/lib/rails/generators/active_record/model/templates | |
parent | f176b2552ecc06634dae53b82a4562d8e80aeed6 (diff) | |
download | rails-3b9120fa52b76fb8591fe1d0db85d1a940e867d0.tar.gz rails-3b9120fa52b76fb8591fe1d0db85d1a940e867d0.tar.bz2 rails-3b9120fa52b76fb8591fe1d0db85d1a940e867d0.zip |
Generate add_index by default when giving type belongs_to or references
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model/templates')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/migration.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb index 70e064be21..7d4e1a7404 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb @@ -8,6 +8,10 @@ class <%= migration_class_name %> < ActiveRecord::Migration t.timestamps <% end -%> end + +<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> + add_index :<%= table_name %>, :<%= attribute.name %>_id +<% end -%> end def down |