diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/through_association.rb | 12 |
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, |