Permalink
Browse files

Use association_class method which returns the reflection class, this…

… method is redefined in polymorphic belongs to associations.
  • Loading branch information...
1 parent f3722a3 commit c036caf501c8efc378d72377f3876ad23742f84d @miloops miloops committed Oct 14, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/associations/association_proxy.rb
@@ -254,8 +254,8 @@ def load_target
return nil unless defined?(@loaded)
if !loaded? and (@owner.persisted? || foreign_key_present)
- if IdentityMap.enabled? && ActiveRecord.const_defined?(@reflection.class_name)
- @target = IdentityMap.get(@reflection.klass, @owner[@reflection.association_foreign_key])
+ if IdentityMap.enabled? && association_class
+ @target = IdentityMap.get(association_class, @owner[@reflection.association_foreign_key])
end
@target ||= find_target
end
@@ -313,6 +313,10 @@ def set_inverse_instance(record, instance)
def we_can_set_the_inverse_on_this?(record)
false
end
+
+ def association_class
+ @reflection.klass
+ end
end
end
end

0 comments on commit c036caf

Please sign in to comment.