From 7f743233c4e276d1799451478e6718589d270cbd Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Sun, 26 Sep 2010 00:35:39 -0400 Subject: Fix for nested_attributes with has_many association fails when a single record is being updated. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#5705 state:resolved] Signed-off-by: José Valim --- activerecord/test/cases/nested_attributes_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'activerecord/test/cases/nested_attributes_test.rb') diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index 62e073ba8c..75ffd31de3 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -123,6 +123,14 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase assert_equal 's1', ship.reload.name end + def test_has_many_association_updating_a_single_record + Man.accepts_nested_attributes_for(:interests) + man = Man.create(:name => 'John') + interest = man.interests.create(:topic => 'photography') + man.update_attributes({:interests_attributes => {:topic => 'gardening', :id => interest.id}}) + assert_equal 'gardening', interest.reload.topic + end + end class TestNestedAttributesOnAHasOneAssociation < ActiveRecord::TestCase -- cgit v1.2.3