# After\_create and after\_save

**URL:** <https://www.ruby-forum.com/t/after-create-and-after-save/164192>\
**Category:** Rails\
**Created:** [March 29, 2009, 7:59pm UTC](https://www.ruby-forum.com/t/after-create-and-after-save/164192 "2009-03-29T19:59:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [March 29, 2009, 7:59pm UTC](https://www.ruby-forum.com/t/after-create-and-after-save/164192/1 "2009-03-29T19:59:47Z")

</div>

Hi,

AFAIK after\_create is called after\_save if the entry does not exist in  
the DB.

Is there a way to tell if a specific model is new or not in  
after\_save?

I have to do something like:  
def after\_save  
add\_to\_history ‘save’  
end

def after\_create  
add\_to\_history ‘create’  
end

However after\_save is called when creating too.

–  
cheers,  
M.

---

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [March 29, 2009, 8:18pm UTC](https://www.ruby-forum.com/t/after-create-and-after-save/164192/2 "2009-03-29T20:18:34Z")

</div>

On Mar 29, 6:59 pm, Marcelo B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> AFAIK after\_create is called after\_save if the entry does not exist in  
> the DB.
> 
> Is there a way to tell if a specific model is new or not in  
> after\_save?

This doesn’t directly answer your question but may still address the  
root concern: take a look at after\_update.

Fred

---

<div class="post-metadata">

**Author:** ![arvias](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac91a4/32.png) [@arvias](https://www.ruby-forum.com/u/arvias)\
**Post date:** [March 30, 2009, 3:45am UTC](https://www.ruby-forum.com/t/after-create-and-after-save/164192/3 "2009-03-30T03:45:46Z")

</div>

after\_save works on both create and updates, you will need to use  
after\_update…??

Richard
