AASM:从任何州过渡?
我正在使用 AASM。是否可以从任何状态转换?例如:
aasm_event :publish do
transitions :to => :publish, :from => ANY_STATE
end
我知道可以将状态数组传递给 :from
,但这不是我想要的。我尝试完全省略 :from
,但这不起作用。
I am using AASM. Is it possible to transition from any state? For example:
aasm_event :publish do
transitions :to => :publish, :from => ANY_STATE
end
I know that it is possible to pass an array of states to :from
, but this isn't what I'm after. I have tried omitting the :from
completely, but that didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
aasm 现在支持不指定任何
from
的转换,这将允许从任何状态转换。(吹牛的权利:我添加这个功能是因为我需要它)
aasm now supports transitions without any
from
specified, which will allow transitioning from any state.(bragging rights: I added this feature because I needed it)
您可以通过
aasm_states
类方法获取状态,前提是它们已在代码中的前面定义。You can get the states via the
aasm_states
class method, provided they have already been defined earlier in the code.