aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/association_preload.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/association_preload.rb')
-rw-r--r--activerecord/lib/active_record/association_preload.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb
index c94b2ff564..95bbaf00cf 100644
--- a/activerecord/lib/active_record/association_preload.rb
+++ b/activerecord/lib/active_record/association_preload.rb
@@ -159,6 +159,11 @@ module ActiveRecord
association_proxy.__send__(:set_inverse_instance, associated_record, mapped_record)
end
end
+
+ id_to_record_map.each do |id, records|
+ next if seen_keys.include?(id.to_s)
+ records.each {|record| record.send("set_#{reflection_name}_target", nil) }
+ end
end
# Given a collection of ActiveRecord objects, constructs a Hash which maps