Use association_class method which returns the reflection class, this method is redefined in polymorphic belongs to associations.
This commit is contained in:
parent
f3722a30b6
commit
c036caf501
|
@ -254,8 +254,8 @@ module ActiveRecord
|
||||||
return nil unless defined?(@loaded)
|
return nil unless defined?(@loaded)
|
||||||
|
|
||||||
if !loaded? and (@owner.persisted? || foreign_key_present)
|
if !loaded? and (@owner.persisted? || foreign_key_present)
|
||||||
if IdentityMap.enabled? && ActiveRecord.const_defined?(@reflection.class_name)
|
if IdentityMap.enabled? && association_class
|
||||||
@target = IdentityMap.get(@reflection.klass, @owner[@reflection.association_foreign_key])
|
@target = IdentityMap.get(association_class, @owner[@reflection.association_foreign_key])
|
||||||
end
|
end
|
||||||
@target ||= find_target
|
@target ||= find_target
|
||||||
end
|
end
|
||||||
|
@ -313,6 +313,10 @@ module ActiveRecord
|
||||||
def we_can_set_the_inverse_on_this?(record)
|
def we_can_set_the_inverse_on_this?(record)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def association_class
|
||||||
|
@reflection.klass
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue