I’m thinking of using before_destroy for it, but don’t know how to
“cancel” deletion in my code in before_destroy “decides” that deletion
should be restricted.
According to the Rails doc, all you need to do is return false from your
before_destroy method. Here’s the relevant section:
== Cancelling callbacks
If a before_* callback returns false, all the later callbacks and
the associated action are cancelled. If an after_* callback returns
false, all the later callbacks are cancelled. Callbacks are
generally run in the order they are defined, with the exception of
defined as methods on the model, which are called last.
Hope this helps,