aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader.rb')
-rw-r--r--activerecord/lib/active_record/associations/preloader.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb
index dca7179953..1be5de708e 100644
--- a/activerecord/lib/active_record/associations/preloader.rb
+++ b/activerecord/lib/active_record/associations/preloader.rb
@@ -112,10 +112,10 @@ module ActiveRecord
end
def preload_hash(association)
- association.each do |parent, child|
- Preloader.new(records, parent, preload_scope).run
+ association.flat_map { |parent, child|
+ preload_one parent
Preloader.new(records.map { |record| record.send(parent) }.flatten, child).run
- end
+ }
end
# Not all records have the same class, so group then preload group on the reflection