From a282301a77288252d135855d088f20de2397998e Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 18 Jan 2011 16:33:18 -0800 Subject: we have a method for setting preloaded records, so use it --- activerecord/lib/active_record/association_preload.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 8e71c6eec5..cba4bab3ef 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -166,9 +166,7 @@ module ActiveRecord id_to_record_map.each do |id, records| next if seen_keys.include?(id) - records.each do |record| - record.send(:association_proxy, reflection_name).target = nil - end + add_preloaded_record_to_collection(records, reflection_name, nil) end end @@ -239,9 +237,7 @@ module ActiveRecord id_to_record_map = construct_id_map(records, reflection.options[:primary_key]) options = reflection.options - records.each do |record| - record.send(:association_proxy, reflection.name).target = nil - end + add_preloaded_record_to_collection(records, reflection.name, nil) if options[:through] through_records = preload_through_records(records, reflection, options[:through]) -- cgit v1.2.3