如何访问特定 Rails 模型的 acts_as_state_machine 状态集合?
是否可以访问给定模型的状态集合:
Conversation 类 包括 AASM
aasm_initial_state :unread
aasm_state :unread
aasm_state :read
aasm_state :closed
aasm_event :view do
transitions :to => :read, :from => [:unread]
end
aasm_event :close do
transitions :to => :closed, :from => [:read, :unread]
end
端
我希望能够获得一系列状态,例如:
['unread', 'read', 'closed']
这可能吗?
Is it possible to access the collection of states for the given model:
class Conversation
include AASM
aasm_initial_state :unread
aasm_state :unread
aasm_state :read
aasm_state :closed
aasm_event :view do
transitions :to => :read, :from => [:unread]
end
aasm_event :close do
transitions :to => :closed, :from => [:read, :unread]
end
end
I would like to be able to get an array of states like:
['unread', 'read', 'closed']
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AASM gem 有两个类方法,它们返回给定模型的状态集合:
例如:
The AASM gem has two class methods that return a collection of states for a given model:
For instance: