This project is archived and is in readonly mode.
has_one :through with decorated join model saves incorrectly
-
Matt Jones
- Tag changed from 2.2.rc1, bug, edge, has_one_through to 2.2.rc1, bug, edge, has_one_through, patch
Update: Some digging tracked this down to HasOneThroughAssociation#create_through_record; it was always deleting the join model record. The attached patch instead uses update_attributes if the join model already exists, and includes tests.
Two of the tests in the previous patch were removed; adding records to the association from the other side doesn't work correctly. Thus
@organization.members << @memberwill still yield bad behavior - but I'm not sure if it should work. The has_many :through on @organization doesn't know anything about the associations defined on @member. Maybe there needs to be a warning in the docs?
-
Michael Koziarski
- State changed from new to resolved
Nice find,
Yeah, the inverses of associations don't work anywhere in rails at present. The same is true with a simple has_many /belongs_to.
Ideally we can fix that in 2.3, but depends on people getting the time and motivation
Fixed for 2-2 and master.
