diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-23 16:46:48 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-23 16:46:48 -0700 |
commit | 6e5a2cb9519aab568ea0cfea2f42364de8ccf655 (patch) | |
tree | f9a7062a14eca6b277d95c1ef4223aaaf678f3dd /activerecord/lib/active_record/associations/preloader | |
parent | 5b432811d73e710f4a703673c531a23ab8660910 (diff) | |
download | rails-6e5a2cb9519aab568ea0cfea2f42364de8ccf655.tar.gz rails-6e5a2cb9519aab568ea0cfea2f42364de8ccf655.tar.bz2 rails-6e5a2cb9519aab568ea0cfea2f42364de8ccf655.zip |
remove state from the preloader
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/through_association.rb | 19 |
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 } |