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.rb19
1 files changed, 9 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index 7849810151..be3e179543 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -16,10 +16,10 @@ module ActiveRecord
return @associated_records_by_owner if @associated_records_by_owner
- left_loader = Preloader.new(owners,
- through_reflection.name,
- through_scope)
- left_loader.run
+ left_loader = Preloader.new
+ left_loader.preload(owners,
+ through_reflection.name,
+ through_scope)
should_reset = (through_scope != through_reflection.klass.unscoped) ||
(reflection.options[:source_type] && through_reflection.collection?)
@@ -37,13 +37,12 @@ module ActiveRecord
middle_records = through_records.map { |(_,rec,_)| rec }.flatten
- preloader = Preloader.new(middle_records,
- source_reflection.name,
- reflection_scope)
+ preloader = Preloader.new
+ preloaders = preloader.preload(middle_records,
+ source_reflection.name,
+ reflection_scope)
- preloader.run
-
- middle_to_pl = preloader.preloaders.each_with_object({}) do |pl,h|
+ middle_to_pl = preloaders.each_with_object({}) do |pl,h|
pl.owners.each { |middle|
h[middle] = pl
}