From bc77ccacbd7fe31a596be2b05a88048f2b832549 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 20 Sep 2013 17:09:48 -0700 Subject: split up construction and mutation --- .../lib/active_record/associations/preloader/through_association.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'activerecord/lib') 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! -- cgit v1.2.3