grosser / soft_deletion

Explicit soft deletion for ActiveRecord via deleted_at and default scope
MIT License
69 stars 27 forks source link

Don't really want to nullify upon soft deletion #40

Open joelmichael opened 6 years ago

joelmichael commented 6 years ago

Recently I've been adding some functionality to our app to hard-delete certain records in order to comply with European regulations. As a result of this, I've been adding dependent: :nullify to a lot of our associations.

The comment I want to make is that I think soft_deletion should basically disregard the "nullify" option. It only really has any relevance in the case of hard deletion, where we nonetheless are willing to keep certain orphaned records around. We do still use soft_deletion in most cases, and I don't want to set these records as :destroy just to avoid soft_delete nullifying them.

I figured this is worth discussing so I decided to make an issue about it. Thanks for the gem.

grosser commented 6 years ago

so change would need to go https://github.com/grosser/soft_deletion/blob/master/lib/soft_deletion/dependency.rb#L12-L13

downside would be that using the association triggers a query that then returns nil ... so kinda inefficient

so far the approach here was to delete things that cannot be soft-deleted to avoid weird bugs from nils/unfindables ... so I think nulling them is more consistent ... would be open to a PR to make that optional though since it's not very obvious what the behavior should be