diff options
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/generators/generated_attribute.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index d480fc12b5..35cd40d25e 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -8,6 +8,7 @@ module Rails attr_accessor :name, :type attr_reader :attr_options + attr_writer :index_name class << self def parse(column_definition) @@ -94,7 +95,7 @@ module Rails end def index_name - if reference? + @index_name ||= if reference? polymorphic? ? %w(id type).map { |t| "#{name}_#{t}" } : "#{name}_id" else name |