The ActiveRecord Hook Execution Chain
Categories: activerecord, tips
ActiveRecord executes hooks in the following order (source):
- save called
- valid called
- before_validation hook called
- before_validation_on_create/before_validation_on_update called
- validate called
- validate_on_create validate_on_update called
- after_validation called
- after_validation_on_create/after_validation_on_update called
- before_save called
- before_create/before_update called
- create/update (at last)
- after_create/after_update called
- after_save called
Comments