Rails cheat sheet: Active Record Callbacks

Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic before or after an alteration of the object state.

Here is a list with all the available Active Record callbacks, listed in the same order in which they will get called during the respective operations:

Creating an Object

before_validation
after_validation
before_save
around_save
before_create
around_create
after_create
after_save

Updating an Object

before_validation
after_validation
before_save
around_save
before_update
around_update
after_update
after_save

Destroying an Object

before_destroy
around_destroy
after_destroy

Leave a Reply

Your email address will not be published. Required fields are marked *