This project is archived and is in readonly mode.
ActiveRecord associations .build does not set associations.
Reported by dlikhten | April 28th, 2010 @ 08:01 PM
object2 = object1.object2s.build
When the above code executes, the expected behavior is
object2.object1 == object1
however the actual behavior is
object2.object1 == nil
The workaround is
object2 = object1.object2s.build
object2.object1 = object1
Comments and changes to this ticket
-
Ryan Bigg April 29th, 2010 @ 12:50 AM
Please create a failing test case for this issue in the form of a patch.
-
Ryan Bigg April 29th, 2010 @ 12:52 AM
- State changed from new to duplicate
Duplicate of #990. Please apply the patch to this ticket.
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>
Referenced by
- 990 association#build inconsistency Marked a similar ticket, #4497, as a duplicate of this on...