Jas*_*rer 6 ruby-on-rails state-machine aasm
我成功地将最新的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
Run Code Online (Sandbox Code Playgroud)
现在我想让管理员通过AASM状态创建自己的图表.因此,我创建了另外两个名为OrderFlow和Transition的模型,其中order_flow有许多转换,订单为belongs_to order_flow.
到目前为止没问题.现在我想让我的管理员可以动态地将现有的转换/事件添加到order_flow图.
现在的问题是,我没有找到任何可能从我的订单模型中获取所有事件/转换的列表.aasm_states_for_select似乎是正确的候选人,但我不能在我的订单模型上调用它.
有人可以帮忙吗?
Thx提前.J.
使用 version 3.0.18,您应该使用ClassName.aasm.states
我不明白 OrderFlow 如何与订单和转换配合使用,但我假设您只是将其包含在内以更好地解释您的场景。
ClassName.aasm_states_for_select 为您提供模型中声明的状态列表。
| 归档时间: |
|
| 查看次数: |
4969 次 |
| 最近记录: |