Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

only do the should_reset test once

  • Loading branch information...
commit 761722287b894b12acb80713388cfbf7fe74eccf 1 parent b4aae5a
@tenderlove tenderlove authored
View
12 activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -27,15 +27,15 @@ def associated_records_by_owner
through_records = owners.map do |owner, h|
association = owner.association through_reflection.name
- x = [owner, Array(association.reader)]
-
- # Dont cache the association - we would only be caching a subset
- association.reset if should_reset
+ [owner, Array(association.reader), association]
+ end
- x
+ # Dont cache the association - we would only be caching a subset
+ if should_reset
+ through_records.each { |(_,_,assoc)| assoc.reset }
end
- middle_records = through_records.map { |(_,rec)| rec }.flatten
+ middle_records = through_records.map { |(_,rec,_)| rec }.flatten
preloader = Preloader.new(middle_records,
source_reflection.name,
Please sign in to comment.
Something went wrong with that request. Please try again.