After_create and after_save


#1

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.


#2

On Mar 29, 6:59 pm, Marcelo B. 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


#3

after_save works on both create and updates, you will need to use
after_update…??

Richard