diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/association_proxy.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 2024cee968..52cb164550 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -253,9 +253,9 @@ module ActiveRecord def load_target return nil unless defined?(@loaded) - if !loaded? and (!@owner.persisted? || foreign_key_present) - if IdentityMap.enabled? - @target = IdentityMap.get(@reflection.class_name, @owner[@reflection.association_foreign_key]) + if !loaded? and (@owner.persisted? || foreign_key_present) + if IdentityMap.enabled? && defined?(@reflection.klass) + @target = IdentityMap.get(@reflection.klass, @owner[@reflection.association_foreign_key]) end @target ||= find_target end |