This project is archived and is in readonly mode.

#4642 ✓resolved
James Le Cuirot

Unsaved changes to nested attribute collections are lost when using collection

Reported by James Le Cuirot | May 18th, 2010 @ 05:05 PM | in 3.0.2

Commit 5efb1503dd88b59fe491dade92790c3f06293445 causes unsaved changes to records in nested attribute collections to be lost when the collection is used afterwards. This is because the collection is no longer loaded when the update occurs and any subsequent loading afterwards erases the changes.

I tried to find some reasonable way to work around this but even using the new association callbacks doesn't work. If I load the collection with the before_add callback, the record then appears in the collection twice, once from the load and once from the update. Having to load the collection explicitly before any update is just a pain.

I think this feature is fundamentally broken unless some extra code is written to append the records that haven't been updated instead. I therefore would like to see this commit reverted. Attached is a failing test case.

Assigning this to Pratik as it was his commit.

Comments and changes 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>