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

Ensures destroy and restore operations are wrapped in a transaction that is rolled back when the callback chain is halted #71

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alecdotninja
Copy link
Contributor

Without this patch, DestroyedAt#destroy does not roll back the transaction when the callback chain is halted. This deviates from the standard ActiveRecord behavior and breaks several features. It is particularly dangerous for associations using dependent: :restrict_with_error which are silently destroyed.

The same semantics have been extended to DestroyedAt#restore. I've also added a DestroyedAt#restore! and corresponding error class (DestroyedAt::RecordNotRestored) to mimic ActiveRecord::Base#destroy! and friends.

…hat is rolled back when the callback chain is halted
@alecdotninja
Copy link
Contributor Author

Coincidently, this also solves #56.

@michaeldupuisjr
Copy link
Contributor

Thank you for the PR @anarchocurious, and I apologize for the delay in getting merged in.

It looks like this branch needs to be rebased, as we have a conflict based off of the work in ae82efb. Please ping me when you have a chance to rebase and I will get this merged in.

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants