# Distinguishing "update or create context" from within after\_

**URL:** <https://www.ruby-forum.com/t/distinguishing-update-or-create-context-from-within-after/92006>\
**Category:** Rails\
**Created:** [April 14, 2007, 12:18pm UTC](https://www.ruby-forum.com/t/distinguishing-update-or-create-context-from-within-after/92006 "2007-04-14T12:18:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rovnak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4bbf92/32.png) [@rovnak](https://www.ruby-forum.com/u/rovnak)\
**Post date:** [April 14, 2007, 12:18pm UTC](https://www.ruby-forum.com/t/distinguishing-update-or-create-context-from-within-after/92006/1 "2007-04-14T12:18:12Z")

</div>

Hi,  
Of course, I like the callbacks in active record. However, it seems  
that it would be valuable to be able to distinguish whether an  
after\_save is being invoked as part of a create as opposed to part of  
an update scenario.

Is there a best practice for doing this? I assume I can set a flag int  
he create or update methods and check in the after\_save, but not sure  
if this is best practice.

---

<div class="post-metadata">

**Author:** ![rovnak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/4bbf92/32.png) [@rovnak](https://www.ruby-forum.com/u/rovnak)\
**Post date:** [April 14, 2007, 8:45pm UTC](https://www.ruby-forum.com/t/distinguishing-update-or-create-context-from-within-after/92006/2 "2007-04-14T20:45:49Z")

</div>

You mean like using the after\_create and after\_update callbacks instead?

🙂

b
