JackDanger/permanent_records — Issue #13: before_destroy callback fires after the record has already been marked as deleted
Author: ahorner
Created: 2012-02-27 21:56:40+00:00
State: open

This problem rears its ugly head when you have a `before_destroy` callback that attempts to navigate a record's associations or find a deleted record.

The `set_deleted_at` method performs a `save!` before the callbacks are ever triggered, so the record is marked as deleted before the callbacks fire, which is inconsistent with the expected order of events:

1. `before_destroy`
2. _record is destroyed_
3. `after_destroy`

This issue is particularly noticeable when you have a `default_scope` applied to a model.