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

after_destroy_commit callback is not triggered on soft delete #450

Closed
cweyer opened this issue Aug 1, 2018 · 7 comments
Closed

after_destroy_commit callback is not triggered on soft delete #450

cweyer opened this issue Aug 1, 2018 · 7 comments
Labels

Comments

@cweyer
Copy link

cweyer commented Aug 1, 2018

According to the documentation (and also tested behaviour) acts_as_paranoid classes trigger the after_destroy callbacks whenever an object is soft-deleted and after_real_destroy when the object is really removed from the database. However there is another AR callback called "after_destroy_commit" which are not triggered on soft-delete. This caused a bug in our implementation, as I would expect it to be desired behaviour that after_destroy_commit callbacks are actually triggered on soft delete. The callback could be fired once the deleted_at-update commit has been committed to the database.

@jamescontent
Copy link

We have had to avoid the use of after_destroy_commit and after_commit :some_hook, on: :destroy altogether because of the way destroy is monkey-patched in this gem. I don't think it's the end of the world for our purposes, but it does seem problematic to not support after_commit callbacks.

@strom2357
Copy link

For what it's worth there's a pull request that purports to resolve this that's been open a while now:
#404

@dillon9693
Copy link

This appears to be fixed as part of v2.4.3. I just updated to latest version, and it's now working as expected (was previously on v2.4.2).

Looks like #482 actually fixed it

@snogrammer
Copy link

@dillon9693 @hashwin

This is still not working for me. Any advice on how you triggered the callbacks in Rails 6?

Tried with the following:

  • rails 6.0.3 (and 6.1.3.1)
  • paranoia 2.4.3

Neither after_commit or after_destroy get trigged when calling Object.destroy

@wchan2
Copy link

wchan2 commented Apr 26, 2022

I'm also still experiencing the same thing for before_destroy with paranoia version 2.6.0 and rails 7.0.2.3.

@mathieujobin
Copy link
Collaborator

I'd like to know what is causing it, I haven't been able to track it down...

@mathieujobin mathieujobin added bug and removed stale labels Apr 26, 2022
@wchan2
Copy link

wchan2 commented Apr 27, 2022

@mathieujobin False alarm. Realized the code was calling .delete on the model and not destroy. It's working correctly now. Apologies for the confusion.

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

No branches or pull requests

7 participants