Skip to content
Browse files

the hash should only ever be length one, so decompose it

  • Loading branch information...
1 parent 7a89043 commit 18dccdccf75e4084718622f578a1ff98f2da6955 @tenderlove tenderlove committed Sep 20, 2013
Showing with 5 additions and 4 deletions.
  1. +5 −4 activerecord/lib/active_record/associations/preloader.rb
View
9 activerecord/lib/active_record/associations/preloader.rb
@@ -116,10 +116,11 @@ def preload(association, records)
end
def preload_hash(association, records)
- association.flat_map { |parent, child|
- preload_one parent, records
- run_preload Array.wrap(child), records.map { |record| record.send(parent) }.flatten.compact.uniq
- }
+ parent, child = association.to_a.first # hash should only be of length 1
+
+ preload_one parent, records
+ run_preload Array.wrap(child),
+ records.map { |record| record.send(parent) }.flatten.compact.uniq
end
# Not all records have the same class, so group then preload group on the reflection

0 comments on commit 18dccdc

Please sign in to comment.
Something went wrong with that request. Please try again.