aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-03-04 09:33:02 +0000
committerJon Leighton <j@jonathanleighton.com>2011-03-04 20:36:11 +0000
commita5ef8b9fa0b30f73af206145cfc39228cb6b9526 (patch)
treecffdc4b83a1fabf6f27c682c1d911a9b22b8abc7 /activerecord
parent735844db712c511dd8abf36a5279318fbc0ff9d0 (diff)
parent1db4969dc9cabed9db162e7194b9353d43c967d7 (diff)
downloadrails-a5ef8b9fa0b30f73af206145cfc39228cb6b9526.tar.gz
rails-a5ef8b9fa0b30f73af206145cfc39228cb6b9526.tar.bz2
rails-a5ef8b9fa0b30f73af206145cfc39228cb6b9526.zip
Merge branch 'master' into nested_has_many_through
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG4
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb5
2 files changed, 5 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 3a63c08b2d..f82bd0da92 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -163,10 +163,6 @@
end
[Santiago Pastorino]
-<<<<<<< Updated upstream
->>>>>>> association_fixes
-=======
->>>>>>> Stashed changes
* Setting the id of a belongs_to object will update the reference to the
object. [#2989 state:resolved]
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index ad6374d09a..30558ae29c 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -33,8 +33,13 @@ module ActiveRecord
through_options
).run
+ # TODO: Verify that this is actually necessary and not just a symptom of an
+ # underlying inefficiency
+ identity_map = {}
+
Hash[owners.map do |owner|
through_records = Array.wrap(owner.send(through_reflection.name))
+ through_records.map! { |record| identity_map[record] ||= record }
# Dont cache the association - we would only be caching a subset
if reflection.options[:source_type] && through_reflection.collection?