Permalink
Browse files

fix merging the targer lists in 1.8.

For some reason, #delete(record) didn't return the record in memory, but the persisted one.
This could be considered as a bug, which is fixed in 1.9.
  • Loading branch information...
1 parent 7278547 commit 8f819904450c8162f8ca38fdadbbd749fc71073c @dmathieu dmathieu committed May 31, 2011
Showing with 2 additions and 3 deletions.
  1. +2 −3 activerecord/lib/active_record/associations/collection_association.rb
@@ -402,9 +402,8 @@ def merge_target_lists(persisted, memory)
return memory if persisted.empty?
persisted.map! do |record|
- mem_record = memory.delete(record)
-
- if mem_record
+ if mem_id = memory.index(record)
+ mem_record = memory.delete_at(mem_id)
(record.attribute_names - mem_record.changes.keys).each do |name|
mem_record[name] = record[name]
end

0 comments on commit 8f81990

Please sign in to comment.