I have an entry in my Rails application with an after_destroy hook that needs to know why the entry is destroyed. More specifically, if a record is destroyed in a cascade because its parent says dependent: :destroy , it must do something different than if the record was individually destroyed.
I tried to find out if his parent was destroyed? , only to find out that the dependent: :destroy callbacks are executed before the parent is destroyed. This makes sense because he should be able to fail. (i.e. limit).
So how do I do this?
callback ruby-on-rails activerecord
Pelle ten cate
source share