ruby-on-rails – 从AASM模型中获取状态/事件列表
发布时间:2020-12-17 03:18:58 所属栏目:百科 来源:网络整理
导读:我成功地将最新的AASM gem集成到一个应用程序中,使用它来创建向导.在我的情况下,我有一个模型订单 class Order ActiveRecord::Base belongs_to :user has_one :billing_plan,:dependent = :destroy named_scope :with_user,..... snip include AASM aasm_col
我成功地将最新的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有许多转换,订单为belongs_to order_flow. 到目前为止没问题.现在我想让我的管理员可以动态地将现有的转换/事件添加到order_flow图. 现在的问题是,我没有找到任何可能从我的订单模型中获取所有事件/转换的列表. aasm_states_for_select似乎是正确的候选人,但我不能在我的订单模型上调用它. 有人可以帮忙吗? Thx提前. 解决方法
我不明白OrderFlow如何与Order和Transitions一起工作,但我假设你只是为了更好地解释你的场景.
ClassName.aasm_states_for_select为您提供模型中声明的状态列表. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |