From 301dd3d5143077f95bebd434ca2ad1c80c1b5866 Mon Sep 17 00:00:00 2001 From: Emilio Tagua Date: Thu, 14 Oct 2010 12:58:47 -0300 Subject: Use hash[:Post][1] style identity maps for each table. --- activerecord/lib/active_record/associations/association_proxy.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/associations') 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 -- cgit v1.2.3