aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-14 13:23:03 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-14 13:23:03 -0700
commit43a63f6d5ec2026dc7c610394aab37613181fff1 (patch)
tree17afdfaa65a801518471d6a82352c9bd3d2cc4ce /activerecord
parent19b871a0902c4ec3e460a38f41583a7855edd81a (diff)
downloadrails-43a63f6d5ec2026dc7c610394aab37613181fff1.tar.gz
rails-43a63f6d5ec2026dc7c610394aab37613181fff1.tar.bz2
rails-43a63f6d5ec2026dc7c610394aab37613181fff1.zip
the preloader for the RHS has all the preloaded records, so ask it
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index 63d4253e6a..edce1d80c5 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -29,6 +29,8 @@ module ActiveRecord
source_reflection.name,
reflection_scope)
+ @preloaded_records.concat preloaders.flat_map(&:preloaded_records)
+
middle_to_pl = preloaders.each_with_object({}) do |pl,h|
pl.owners.each { |middle|
h[middle] = pl
@@ -53,9 +55,7 @@ module ActiveRecord
}.compact
record_index = pl_indexes[pl]
- records = rhs_records.sort_by { |rhs| record_index[rhs] }
- @preloaded_records.concat rhs_records
- records
+ rhs_records.sort_by { |rhs| record_index[rhs] }
end
}
end