-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Associations are persisted before validation of main record #5430
Comments
So, for anyone having the same issue, I found a workaround, you can define a For this it would be
|
There is a PR ready for this. Thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
When updating a record with changes to its children that make the record fail validation, no changes are saved to the database.
Actual behavior
The invalid association change is persisted, and then the user gets redirected to a form displaying a validation error.
How to reproduce
This seems to be due to the behavior of
assign_attributes
(as detailed in http://guides.rubyonrails.org/association_basics.html#has-and-belongs-to-many-association-reference). Maybeupdate_resource
should check if anids
field is present, and if so usecollection.build
for that?The text was updated successfully, but these errors were encountered: