我有一个模型如下
class Inspection < ActiveRecord::Base
include AASM
aasm_column :status #aasm in 'status' field
aasm_initial_state :new
aasm_state :new
aasm_state :inprocess
aasm_state :complete
aasm_state :approved
aasm_event :inprocess do
transitions :to => :inprocess, :from => :new
end
aasm_event :complete do
transitions :to => :complete, :from => :inprocess
end
aasm_event :approve do
transitions :to => :approved, :from => :complete
end
aasm_column :sharing_status #aasm in 'sharing_status' field
aasm_initial_state :not_shared
aasm_state :not_shared
aasm_state :shared
aasm_state :revoked
aasm_event :share do
transitions :to => :shared, :from => :not_shared
end
aasm_event :revoke do
transitions :to => :revoked, :from => :shared
end
.....
end我想要在两个不同的模型字段上实现不同的aasm状态和转换, of Inspection。第一个转换在上述代码中不起作用(如果存在第二种状态和转换)。如何解决这一问题?
发布于 2013-10-14 12:29:29
我有同样的问题,似乎AASM不支持在同一个模型上有多个状态模型,但是插件'state_machine‘确实支持这一点。
https://stackoverflow.com/questions/12671082
复制相似问题