diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-05-14 19:40:24 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-05-14 19:49:22 +0100 |
commit | 60b23ea1da1c119eaab6d07e5a03cf3b5d5577d4 (patch) | |
tree | 3e352279ac70704e426726e848b1687cd0007fdc /activerecord/lib/active_record | |
parent | 6660beef367a888ac633cc03d1d7157737e6b2cb (diff) | |
download | rails-60b23ea1da1c119eaab6d07e5a03cf3b5d5577d4.tar.gz rails-60b23ea1da1c119eaab6d07e5a03cf3b5d5577d4.tar.bz2 rails-60b23ea1da1c119eaab6d07e5a03cf3b5d5577d4.zip |
CollectionAssociation#merge_target_lists should write to the underlying attributes when copying, rather than using the assignment method
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/associations/collection_association.rb | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/collection_association.rb b/activerecord/lib/active_record/associations/collection_association.rb index d551cb01f0..50825a50f0 100644 --- a/activerecord/lib/active_record/associations/collection_association.rb +++ b/activerecord/lib/active_record/associations/collection_association.rb @@ -405,17 +405,14 @@ module ActiveRecord mem_record = memory.delete(record) if mem_record - # FIXME: this call to record.attributes causes many NoMethodErrors - attributes = record.attributes - # Only try to assign attributes which exist on mem_record - shared = mem_record.attribute_names & attributes.keys + shared = mem_record.attribute_names & record.attribute_names # Don't try to assign the primary key, or attributes which have changed on mem_record excluded = ["id"] + mem_record.changes.keys (shared - excluded).each do |key| - mem_record.send("#{key}=", attributes[key]) + mem_record[key] = record[key] end mem_record |