Permalink
Browse files

Prevent pushing duplicated records when using identity map.

  • Loading branch information...
1 parent 7df6175 commit dd6e6808153cd033ac5dd3c431f579f640125293 @miloops miloops committed Sep 13, 2010
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/association_preload.rb
View
2 activerecord/lib/active_record/association_preload.rb
@@ -126,7 +126,7 @@ def add_preloaded_records_to_collection(parent_records, reflection_name, associa
parent_records.each do |parent_record|
association_proxy = parent_record.send(reflection_name)
association_proxy.loaded
- association_proxy.target.push(*Array.wrap(associated_record))
+ association_proxy.target = association_proxy.target | [*Array.wrap(associated_record)]
association_proxy.__send__(:set_inverse_instance, associated_record, parent_record)
end

0 comments on commit dd6e680

Please sign in to comment.