简单的问题,按照保存新项目时首先发生的处理顺序。
:before_create
:validates
答案 0 :(得分:14)
validates
排在第一位。来自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
答案 1 :(得分:2)
before_create
,因此首先调用validates。
答案 2 :(得分:2)
来自http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
(-) 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
答案 3 :(得分:1)
根据docs:
( - )保存
( - )有效
(1)before_validation
( - )验证
(2)after_validation
(3)before_save
(4)before_create
( - )创建
(5)after_create
(6)after_save
(7)after_commit