http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
Active Record Callbacks
Callbacks are hooks into the life cycle of an Active Record object that allow you to trigger logic before or after an alteration of the object state. This can be used to make sure that associated and dependent objects are deleted when destroy is called (by overwriting before_destroy ) or to massage attributes before they’re validated (by overwriting before_validation ). As an example of the callbacks initiated, consider the Base#save call for a new record:
(-) 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
http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html
查看更多关于http://api.rubyonrails.org/classes/ActiveRecord/Ca的详细内容...