MichaelXavier.net

thoughts.find_all(&:sfw?) #A blog on Ruby, Rails, and Software Engineering

The ActiveRecord Hook Execution Chain
01|05|2010 — 0 comments  

Categories: activerecord, tips

ActiveRecord executes hooks in the following order (source):

  1. save called
  2. valid called
  3. before_validation hook called
  4. before_validation_on_create/before_validation_on_update called
  5. validate called
  6. validate_on_create validate_on_update called
  7. after_validation called
  8. after_validation_on_create/after_validation_on_update called
  9. before_save called
  10. before_create/before_update called
  11. create/update (at last)
  12. after_create/after_update called
  13. after_save called

Comments Comments RSS Feed

Add Comment

(required)
(required, won't be displayed)

(Use Markdown syntax)