I have an object A
that has_many B
's (simple association):
has_many :book_accounts, {
dependent: :destroy
}
I was working on a before_destroy
callback. I want to check and make sure that there are no C
's (which belongs_to B
) and D
's (which belongs_to C
) before destroying the A
. I checked the log and all of the B
's are getting deleted before the callback causing the callback to crash.
Is this how Rails is supposed to work? Is there something I can do other than removing the dependent: destroy
and manually destroying the B
's in an after_destroy
callback? Or is that the go-to solution?