我使用Rails中3 ActiveRecord::Transitions
,並有我的狀態機定義爲:轉換類(狀態機)得到可能的轉換列表
state_machine do
state :initial # first one is initial state
state :active
state :disabled
event :activate do
transitions :to => :active, :from => [:initial, :disabled]
end
event :disable do
transitions :to => :disabled, :from => [:initial, :active]
end
end
如何看到一個可用的轉換列表當前對象和狀態? 例如,如果我有狀態的@product
「激活」它應該告訴我
- 「禁用」是唯一的狀態可用,或
- 「禁用」是唯一可用的事件