Given below are the sequence of executions of
ActiveRecord callbacks.
Its handy when you have to execute particular piece of code at
particular time of record creation.
 
For before_persisting callback 
 before_persisting
  persist
  after_persisting
  [save record if record.changed?]
  
For befor_validation callback
  before_validation
  before_validation_on_create
  before_validation_on_update
validate
  after_validation_on_update
  after_validation_on_create
  after_validation
  [save record if record.changed?]
 
For before_create and before_update callback
before_save
before_create
before_update
saves the record
after_update
after_create
after_save
  [save record if record.changed?]
  
For before_destory callback
  before_destroy
  [save record if record.changed?]
  destroy
  after_destroy
No comments:
Post a Comment