From df3cfa6aaea326bb60b639524abbcc1f73854d1f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 23 Dec 2010 07:33:22 -0800 Subject: avoid duping and new objects --- activerecord/lib/active_record/association_preload.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 7f5c5dd2ad..6d905fe6fe 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -211,10 +211,11 @@ module ActiveRecord associated_records_proxy = reflection.klass.unscoped. includes(options[:include]). - joins(join). - select(select). order(options[:order]) + associated_records_proxy.joins_values = [join] + associated_records_proxy.select_values = select + all_associated_records = associated_records(ids) do |some_ids| associated_records_proxy.where([conditions, some_ids]).to_a end -- cgit v1.2.3