From 8d3bf8b66c783419600ad815db8a5405fe573b0b Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Wed, 27 Sep 2017 06:18:23 +0900 Subject: Don't generate `foreign_type` if `options[:polymorphic]` is not given Because the reflection doesn't have `foreign_type` unless the association is a polymorphic association. --- activerecord/lib/active_record/reflection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 032df925bf..97adfb4352 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -426,7 +426,7 @@ module ActiveRecord def initialize(name, scope, options, active_record) super @type = options[:as] && (options[:foreign_type] || "#{options[:as]}_type") - @foreign_type = options[:foreign_type] || "#{name}_type" + @foreign_type = options[:polymorphic] && (options[:foreign_type] || "#{name}_type") @constructable = calculate_constructable(macro, options) @association_scope_cache = Concurrent::Map.new -- cgit v1.2.3