-
Notifications
You must be signed in to change notification settings - Fork 196
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
Can't destroy parent if not paranoid #151
Comments
This behavior is as intended. ActsAsParanoid aims to never allow accidental full destruction of a record. It cannot know that the destruction of Child objects is fine for you in this case. The simplest solution for you would be to explicitly destroy the chidren with Going a bit further, I think there are three behaviors involving deletion of the Child that would be possible for a
It may be possible to add a mechanism to make case 1 work by adding some |
I agree that case 1 would probably be the best fit here, as it would be opt-in ( |
Hi, I've been struggling with exactly this problem for a while. I finally solved it this way: # Parent model
before_destroy do
children.with_deleted.each(&:destroy_fully!)
end You can leave the option Hope this is helpful for someone out there. |
This comment was marked as resolved.
This comment was marked as resolved.
Hi @Atashia-Sameen that looks like a different problem since you're using |
If a parent model isn't paranoid it's impossible to destroy it. It calls
#destroy
on all the children, which doesn't actually delete them, then when it goes to delete the parent, it gets a foreign key violation from the database.Since
Parent
is not paranoid I would expect calling#destroy
to work and fully destroy its children.If I add
acts_as_paranoid
to the parent it works just fine, however I have no need to soft delete the parent.Originally posted by @szechyjs in #142 (comment)
The text was updated successfully, but these errors were encountered: