1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Ryuta Kamizono 2017-09-27 06:18:23 +09:00
parent aa1cf119a6
commit 8d3bf8b66c

View file

@ -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