Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2279 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2005-09-20 18:36:14 +00:00
parent 5213a1f733
commit 66ecf31ffe
3 changed files with 7 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
*SVN*
* Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
* Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
* Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]

View File

@@ -13,8 +13,8 @@ module ActiveRecord
end
def create(attributes = {})
record = build(attributes)
record.save
record = @association_class.create(attributes)
replace(record, true)
record
end

View File

@@ -664,6 +664,9 @@ class BelongsToAssociationsTest < Test::Unit::TestCase
citibank = Account.create("credit_limit" => 10)
apple = citibank.create_firm("name" => "Apple")
assert_equal apple, citibank.firm
citibank.save
citibank.reload
assert_equal apple, citibank.firm
end
def test_building_the_belonging_object