diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 3ca07498c5..4ef361fccf 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -102,14 +102,14 @@ module ActiveRecord @preloaders = [] else @preloaders = associations.flat_map { |association| - preload(association, records) + preloaders_on association, records } end end private - def preload(association, records) + def preloaders_on(association, records) case association when Hash preloaders_for_hash(association, records) @@ -128,7 +128,9 @@ module ActiveRecord loaders = preloaders_for_one parent, records recs = loaders.flat_map(&:target_records).uniq - loaders.concat Array.wrap(child).flat_map { |assoc| preload assoc, recs } + loaders.concat Array.wrap(child).flat_map { |assoc| + preloaders_on assoc, recs + } end # Not all records have the same class, so group then preload group on the reflection |