我成功地将最新的 AASM gem 集成到一个应用程序中,并使用它来创建一个向导。就我而言,我有一个模型订单
class Order < ActiveRecord::Base
belongs_to :user
has_one :billing_plan, :dependent => :destroy
named_scope :with_user, ..... <snip>
include AASM
aasm_column :aasm_state
aasm_initial_state :unauthenticated_user
aasm_state :unauthenticated_user, :after_exit => [:set_state_completed]
aasm_state : <snip>
<and following the event definitions>
end
现在,我想让管理员可以通过 AASM 状态创建自己的图表。因此,我创建了两个额外的模型,称为 OrderFlow 和 Transition,其中 order_flow 有许多转换,而 orderbelongs_to order_flow。
到目前为止没有问题。现在,我想让我的管理员可以将现有的转换/事件动态添加到 order_flow 图。
现在的问题是,我找不到任何可能从我的订单模型中获取所有事件/转换的列表。 aasm_states_for_select 似乎是正确的候选人,但我不能在我的订单模型上调用它。
任何人都可以帮忙吗?
提前谢谢。
J。
最佳答案
与版本 3.0.18
,你可以使用 ClassName.aasm.states
关于ruby-on-rails - 从 AASM 的模型中获取状态/事件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2988920/