Callbacks 回调
# ActiveRecord::Callbacks
define_model_callbacks :initialize, :find, :touch, :only => :after
define_model_callbacks :save, :create, :update, :destroy
# ActiveModel::Callbacks
define_callbacks :validation
# ActiveRecord::Transactions
define_callbacks :commit, :rollback是什么?
有哪些?
CALLBACKS = [
:after_initialize, :after_find, :after_touch,
:before_save, :around_save, :after_save,
:before_create, :around_create, :after_create,
:before_update, :around_update, :after_update,
:before_destroy, :around_destroy, :after_destroy,
:before_validation, :after_validation,
:after_commit, :after_rollback,
:after_create_commit, :after_update_commit, :after_destroy_commit
]怎么使用?
抽取封装回调方法
怎么取消后面的回调?
如何理解 around
一个生命周期为一个事务(BEGIN...COMMIT)
最后更新于