Skip to content

Commit

Permalink
Fixed that the create_x method from belongs_to wouldn't save the asso…
Browse files Browse the repository at this point in the history
…ciation properly #2042 [Florian Weber]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2279 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Sep 20, 2005
1 parent 5213a1f commit 66ecf31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN* *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] * 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] * Improved migrations' behavior when the schema_info table is empty. [Nicholas Seckar]
Expand Down
Expand Up @@ -13,8 +13,8 @@ def reset
end end


def create(attributes = {}) def create(attributes = {})
record = build(attributes) record = @association_class.create(attributes)
record.save replace(record, true)
record record
end end


Expand Down
3 changes: 3 additions & 0 deletions activerecord/test/associations_test.rb
Expand Up @@ -664,6 +664,9 @@ def test_creating_the_belonging_object
citibank = Account.create("credit_limit" => 10) citibank = Account.create("credit_limit" => 10)
apple = citibank.create_firm("name" => "Apple") apple = citibank.create_firm("name" => "Apple")
assert_equal apple, citibank.firm assert_equal apple, citibank.firm
citibank.save
citibank.reload
assert_equal apple, citibank.firm
end end


def test_building_the_belonging_object def test_building_the_belonging_object
Expand Down

0 comments on commit 66ecf31

Please sign in to comment.