2012-01-11 42 views

回答

2

您的初始預感是正確的。僅當驗證通過時纔會調用before_create。這是很容易在你原來的鏈路上觀察到通過看回調的生命週期:

before_validation 
. <----- validations happen here 
after_validation 
before_save 
before_create 
around_create <--- save happens in here 
after_create 
after_save 

如果在任何時候回調,驗證,或保存失敗,則驗證的後面部分/保存週期都跑不了。

+0

謝謝。這正是我需要的。猜猜我需要開始閱讀並停止瀏覽。 – John 2012-01-11 00:49:19

相關問題