0
我正在使用轨4.2.3和aasm宝石版本4.1 是否有可能在一个模型中为枚举字段添加两个状态机?多个状态机在一个模型中用于枚举字段与aasm
我有枚举状态:[:激活,:暂停,:删除] 和枚举活性:[:工作,:停止]
和我不会2的状态机这样的:
aasm(:connection_state, column: :state, enum: true do
state :active, initial: true
state :suspended
state :deleted
event :activate do
transitions from: :suspended, to: :active
transitions from: :deleted, to: :active
end
event :suspend do
transitions from: :active, to: :suspended
end
event :mark_as_deleted do
transitions from: [:active, :suspended], to: :deleted
end
end
等状态机:
aasm(:activity_state, column: :activity, enum: true do
state :working, initial: true
state :stopped
event :start_working do
transitions from: :stopped, to: :working
end
event :stop_working do
transitions from: :working, to: :stopped
end
end
,但规格与错误而失败:
expect(subject).to transition_from(:active).to(:suspended).on_event(:suspend)
AASM :: UnknownStateMachineError: 没有国家机器与MODELNAME
定义的名称 'default' 我很想念?