Ensures destroy and restore operations are wrapped in a transaction that is rolled back when the callback chain is halted
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.
Coincidently, this also solves #56.
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 ae82efb1ee0dcaaf9c6400ddb4f08d60f3ef19f2. Please ping me when you have a chance to rebase and I will get this merged in.
Thanks!