1

如何在 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
4

1 回答 1

5

没关系 - 想通了:

aasm_state :paid, :enter => :update_foo
于 2008-10-30T15:48:17.617 回答