class TestCallback
extend ActiveModel::Callbacks
define_model_callbacks :create
def create
run_callbacks :create do
puts 'Run run_callback'
end
end
before_create :action_before_create
def action_before_create
puts 'Run action_before_create'
end
end
TestCallback.new.create
Result:
Run action_before_create
Run run_callback
沒有留言:
張貼留言