From c801f233df9d20c59d9756a5279365603dc5cbbd Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 16 Nov 2010 13:43:44 -0800 Subject: reloading an association will properly set attributes of instantiated objects. Thanks Brian Palmer [#5802 state:resolved] --- activerecord/lib/active_record/associations/association_collection.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activerecord/lib/active_record/associations/association_collection.rb') diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 7cdd91e9b2..600f59026e 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -379,7 +379,9 @@ module ActiveRecord if i @target.delete_at(i).tap do |t| keys = ["id"] + t.changes.keys + (f.attribute_names - t.attribute_names) - t.attributes = f.attributes.except(*keys) + f.attributes.except(*keys).each do |k,v| + t.send("#{k}=", v) + end end else f -- cgit v1.2.3