Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveRecord, which comes first?

Simple question really, in the order of processing which will happen first when saving a new item.

  1. :before_create
  2. :validates
like image 805
Jeremy B. Avatar asked Dec 01 '22 02:12

Jeremy B.


1 Answers

validates goes first. From the docs:

(-) save
(-) valid
(1) before_validation
(-) validate
(2) after_validation
(3) before_save
(4) before_create
(-) create
(5) after_create
(6) after_save
(7) after_commit
like image 110
tokland Avatar answered Dec 04 '22 09:12

tokland