Skip to content
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

has_many through not rolling back when validation fails #3068

Open
austinbachman opened this issue Sep 20, 2018 · 1 comment
Open

has_many through not rolling back when validation fails #3068

austinbachman opened this issue Sep 20, 2018 · 1 comment

Comments

@austinbachman
Copy link

When a model has_many through, and an association is added when editing the record, but a validation fails when the record is saved, the join table record remains. It appears that the association is being created in a separate transaction than the save, and so it is not being rolled back when the save fails. Although I believe this should not be the expected behavior, please advise if there are any workarounds for this to remove the join record, as when removing them explicitly when validation fails, that change is rolled back and they still persist.

@darrenterhune
Copy link
Contributor

Due to this line https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/actions/edit.rb#L27 which calls assign_attributes in rails which doesn't use validators and is separate from the save so rollbacks don't rollback the associations collection assignments. Also experienced this problem and our solution is building our own admin ui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants