如何在AASM中调用状态更改方法?
当状态转换为以下模型中的付费时,我想调用update_foo:
class Foo < ActiveRecord::Base
include AASM
# State Machine
aasm_initial_state :incomplete
aasm_state :incomplete
aasm_state :paid
aasm_event :pay do
transitions :from => :incomplete, :to => :paid
end
def update_foo
...
end
end
答案 0 :(得分:4)
没关系 - 想通了:
aasm_state :paid, :enter => :update_foo