is there any way, given certain condition, cancel the destroy of an object on the before_destroy callback of active record? Thanks
You should return false
.
"Canceling callbacks
If a before_* callback throws :abort, all the later callbacks and the associated action are cancelled."
"Canceling callbacks
If a before_* callback returns false, all the later callbacks and the associated action are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last."
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With