aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader/through_association.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader/through_association.rb')
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index 2c625cec04..3001177d15 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -14,7 +14,10 @@ module ActiveRecord
def associated_records_by_owner
through_records = through_records_by_owner
- Preloader.new(through_records.values.flatten, source_reflection.name, reflection_scope).run
+ preloader = Preloader.new(through_records.values.flatten,
+ source_reflection.name,
+ reflection_scope)
+ preloader.run
through_records.each do |owner, records|
records.map! { |r| r.send(source_reflection.name) }.flatten!