diff options
author | Michał Łomnicki <michal.lomnicki@gmail.com> | 2011-02-01 23:27:26 +0100 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2011-02-01 22:50:51 -0200 |
commit | 4e390720178889c773adb12ea1f073bc035fbe67 (patch) | |
tree | 9604ba568b7d69b0f4397ff7c51a91cd567e83b7 /activerecord/lib/rails/generators/active_record/model/templates | |
parent | 5b42e9660201fc721075d2bfbe13edb0014dbde2 (diff) | |
download | rails-4e390720178889c773adb12ea1f073bc035fbe67.tar.gz rails-4e390720178889c773adb12ea1f073bc035fbe67.tar.bz2 rails-4e390720178889c773adb12ea1f073bc035fbe67.zip |
Configurable generation of add_index for references columns
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/lib/rails/generators/active_record/model/templates')
-rw-r--r-- | activerecord/lib/rails/generators/active_record/model/templates/migration.rb | 2 |
1 files changed, 2 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 cd2552d9b8..e573e908a7 100644 --- a/activerecord/lib/rails/generators/active_record/model/templates/migration.rb +++ b/activerecord/lib/rails/generators/active_record/model/templates/migration.rb @@ -9,8 +9,10 @@ class <%= migration_class_name %> < ActiveRecord::Migration <% end -%> end +<% if options[:indexes] %> <% attributes.select {|attr| attr.reference? }.each do |attribute| -%> add_index :<%= table_name %>, :<%= attribute.name %>_id <% end -%> +<% end %> end end |