How to determine if a record is just created or updated in after_save

I was looking to use this for an after_save callback.

A simpler solution is to use id_changed? (since it won’t change on update) or even created_at_changed? if timestamp columns are present.

Update: As @mitsy points out, if this check is needed outside of callbacks then use id_previously_changed?. See docs.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)