diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-23 16:51:51 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-09-23 16:51:51 -0700 |
commit | f34d46ab824e3db121d0e02c7859b6aceb8093d9 (patch) | |
tree | 0d45061b7aafb32b1eca0823aa059a17bc5be9cc /activerecord/lib/active_record | |
parent | 6e5a2cb9519aab568ea0cfea2f42364de8ccf655 (diff) | |
download | rails-f34d46ab824e3db121d0e02c7859b6aceb8093d9.tar.gz rails-f34d46ab824e3db121d0e02c7859b6aceb8093d9.tar.bz2 rails-f34d46ab824e3db121d0e02c7859b6aceb8093d9.zip |
reuse the same preloader object for each association
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index efa8cf1c42..cfaf566ec4 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -599,9 +599,9 @@ module ActiveRecord preload = preload_values preload += includes_values unless eager_loading? + preloader = ActiveRecord::Associations::Preloader.new preload.each do |associations| - pl = ActiveRecord::Associations::Preloader.new - pl.preload @records, associations + preloader.preload @records, associations end @records.each { |record| record.readonly! } if readonly_value |