Don't soft-destroy nested records before save#78
Conversation
|
Hello, thanks for the PR @Drakula2k. Seems your e-friend left some excessive comments, please consider removing them if not useful or sharing some historical states. Can you share what risks this brings? Is it 100% backwards compatible (not saying original behaviour was right and intended)? |
|
@simi thanks for checking! Cleaned up the specs and comments. I can't say it's 100% backwards compatible, but almost 😃 On a fairly large codebase of TableCheck monolith I found only 1 case where this change caused a regression: we use So when the same phone is destroyed but then added back (within the same request/parameters) it was implicitly relying on this instant removal to keep the newly added phone. I've added a fix for this by patching |
Currently paranoid nested attributes call destroy_document right when the nested attributes are assigned, regardless of validations on the parent record, or
.savebeing called at all.This PR fixes it.
Here is a bit of git archeology from Claude on this issue: