aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-15 15:38:38 -0300
committerEmilio Tagua <miloops@gmail.com>2010-11-19 19:08:09 -0300
commit234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88 (patch)
treed8835097cfe5c4d63eadf35ddfabd612ce101b18 /activerecord/lib/active_record/associations
parent6b0b95f1bd92e2ef35573cb59e8a14bd3ffb3777 (diff)
downloadrails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.tar.gz
rails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.tar.bz2
rails-234bbe5cb0e31b786cc73e8f63e55a9ce8aecf88.zip
Associated objects are assigned from identity map if enabled and contains associated object.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_proxy.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb
index 7cd04a1ad5..bfedffcf02 100644
--- a/activerecord/lib/active_record/associations/association_proxy.rb
+++ b/activerecord/lib/active_record/associations/association_proxy.rb
@@ -252,8 +252,11 @@ module ActiveRecord
def load_target
return nil unless defined?(@loaded)
- if !loaded? and (@owner.persisted? || foreign_key_present)
- @target = find_target
+ if !loaded? and (!@owner.persisted? || foreign_key_present)
+ if IdentityMap.enabled?
+ @target = IdentityMap.get(@reflection.class_name, @owner[@reflection.association_foreign_key])
+ end
+ @target ||= find_target
end
@loaded = true