# Do AR callbacks know why they were called?

**URL:** <https://www.ruby-forum.com/t/do-ar-callbacks-know-why-they-were-called/176847>\
**Category:** Rails\
**Created:** [October 7, 2009, 12:57am UTC](https://www.ruby-forum.com/t/do-ar-callbacks-know-why-they-were-called/176847 "2009-10-07T00:57:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phallstrom](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f475e1/32.png) [@phallstrom](https://www.ruby-forum.com/u/phallstrom)\
**Post date:** [October 7, 2009, 12:57am UTC](https://www.ruby-forum.com/t/do-ar-callbacks-know-why-they-were-called/176847/1 "2009-10-07T00:57:52Z")

</div>

Hi all -

I was thinking today (dangerous) and got to wondering if AR callbacks  
know why there were called. That is, do they know what triggered them.

Say I have…

class Foo \<\< AR::Base  
before\_destroy :bar

```
before_create :bar

def bar
  # Can I determine if I am creating or destroying here?
end

```

end

Let’s assume for a moment that new\_record? isn’t available as I know  
that would catch the before\_create one, but wouldn’t work for  
before\_save/after\_save/etc…

I didn’t see anything in perusing the docs/source, but might have  
missed it…

Anyone know?

-philip
