title: In rails, How to determine if a record was destroyed by a dependent: :destroy callback?
body: <p>I've got a record in my Rails app with an <code>after_destroy</code> hook that needs to be aware of why the record gets destroyed. More specifically, if the record is being destroyed in a cascade because its parent says <code>dependent: :destroy</code>, it needs to do things differently than if the record was individually destroyed.</p>
  <p>What I tried to do is to see if its parent was <code>destroyed?</code>, only to figure out that <code>dependent: :destroy</code> callbacks are done before the parent is destroyed. Which makes sense because it should be able to fail. (i.e. restrict).</p>
  <p>So, how do I do this?</p>