diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-10-14 15:40:35 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-11-19 19:08:54 -0300 |
commit | c036caf501c8efc378d72377f3876ad23742f84d (patch) | |
tree | c75782b8ac03954a9d95a27ccdf7f67f5d6e06c8 /activerecord/lib | |
parent | f3722a30b63f45add2e6e03c4e7498b46628b60b (diff) | |
download | rails-c036caf501c8efc378d72377f3876ad23742f84d.tar.gz rails-c036caf501c8efc378d72377f3876ad23742f84d.tar.bz2 rails-c036caf501c8efc378d72377f3876ad23742f84d.zip |
Use association_class method which returns the reflection class, this method is redefined in polymorphic belongs to associations.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index cb8d8b4a7b..9a9ffe9d62 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -254,8 +254,8 @@ module ActiveRecord 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 @@ module ActiveRecord def we_can_set_the_inverse_on_this?(record) false end + + def association_class + @reflection.klass + end end end end |