-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add dependent: :destroy on snapshots #40
Comments
There is this comment in the readme
My initial reaction is that I want to keep that approach. However as I think about it, if you are deleting the record than its probable that you would want the snapshots deleted too. If you really wanted to keep the snapshots I suspect you would actually mark your record as inactive/archived. Maybe an option could be helpful. As it stands however I think its easy enough to just modify your destroy method, even if it does seem a little non-intuitive. class User < ApplicationRecord
def destroy
destroyed = super
if destroyed
Snapshot.where(item_type: self.class.name, item_id: id).destroy_all
end
return destroyed
end
end |
Is it possible to add in the future the ability to have dependent delete on the snapshots? If a user removes himself from our app we would like to have all his snapshots removed also without having to do it through a method manually.
The text was updated successfully, but these errors were encountered: