aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-09-23 16:17:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-09-23 16:17:15 -0700
commit761722287b894b12acb80713388cfbf7fe74eccf (patch)
treee3475c0eef5286f946b6acb59cd8926ec4549560 /activerecord/lib/active_record/associations/preloader
parentb4aae5a8e6a3d65b11490261b445faf9e38bbcd2 (diff)
downloadrails-761722287b894b12acb80713388cfbf7fe74eccf.tar.gz
rails-761722287b894b12acb80713388cfbf7fe74eccf.tar.bz2
rails-761722287b894b12acb80713388cfbf7fe74eccf.zip
only do the should_reset test once
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader')
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index 09d1281ccc..7849810151 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -27,15 +27,15 @@ module ActiveRecord
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,