Skip to content
lukasalexandre edited this page Dec 21, 2012 · 1 revision

###Overview Callbacks can be used to execute code on predetermined moments.

####Usage

after_create do
  self.do_something
end

self refers to the instance you are in

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

####Finding an Object

  • after_initialize
  • after_find

####Creating an Object

  • after_initialize
  • before_validation
  • after_validation
  • before_save
  • before_create
  • after_create
  • after_save

####Updating an Object

  • before_validation
  • after_validation
  • before_save
  • before_update
  • after_update
  • after_save

####Destroying an Object

  • before_destroy
  • after_destroy
Clone this wiki locally