This project is archived and is in readonly mode.
autosave for has_one does not work properly with primary_key option
Reported by ransom-briggs (at uiowa) | June 17th, 2009 @ 10:59 PM | in 2.3.6
Running into problems with :primary key option and autosave association - it sets it back to the id column of the parent instance when it shouldn't be saving it at all - it also sets it incorrectly
using the models from the test suite
f = Firm.new(:name => 'Firm with account_using_primary_key', :firm_id => 2)
a = Account.create(:credit_limit => 20, :firm_id => f.firm_id)
assoc = f.account_using_primary_key(true)
f.save
this code sets a.firm_id = f.id and then saves when it should not save - the test I wrote is pretty crummy - I just freeze the Account and show that it bails when trying to save the Firm - but will show the problem where it is saving when it should not
I also attached a passing patch which should do both things - alter the check if it should save - and set the proper value which is :primary_key if set, id if not
Comments and changes to this ticket
-
ransom-briggs (at uiowa) June 18th, 2009 @ 02:25 PM
Adding a test for setting the foreign key as well
-
Eloy Duran July 12th, 2009 @ 12:39 PM
- State changed from new to verified
- Milestone changed from 2.x to 2.3.4
I have verified and fixed this on my branch of 2-3-stable, which Micheal will look at and merge in before 2.3.4.
http://github.com/alloy/rails/commit/e5de99082a7d151a70e8d48b96471f...
Thanks!
-
Jeremy Kemper September 11th, 2009 @ 11:04 PM
- Milestone changed from 2.3.4 to 2.3.6
[milestone:id#50064 bulk edit command]
-
Repository September 13th, 2009 @ 02:33 AM
- State changed from verified to resolved
(from [a070873771ebede9097735f07fc40720dce89c46]) Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [#1756 state:resolved]
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]
Signed-off-by: Eloy Duran eloy.de.enige@gmail.com
http://github.com/rails/rails/commit/a070873771ebede9097735f07fc407... -
Repository September 13th, 2009 @ 02:33 AM
(from [c01be9de322ba846923340e41e69821d01541610]) Fix has_one with foreign_key and primary_key association bug which caused the associated object being lost when saving the owner. [#1756 state:resolved]
Mixed in a bit from patch by ransom-briggs. [#2813 state:resolved]
Signed-off-by: Eloy Duran eloy.de.enige@gmail.com
http://github.com/rails/rails/commit/c01be9de322ba846923340e41e6982...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1756 has_one with :foreign_key & :primary_key bug Mixed in a bit from patch by ransom-briggs. [#2813 state:...
- 2813 autosave for has_one does not work properly with primary_key option Mixed in a bit from patch by ransom-briggs. [#2813 state:...
- 1756 has_one with :foreign_key & :primary_key bug Mixed in a bit from patch by ransom-briggs. [#2813 state:...
- 2813 autosave for has_one does not work properly with primary_key option Mixed in a bit from patch by ransom-briggs. [#2813 state:...