I successfully integrated the most recent AASM gem into an application, using it for the creation of a wizard. In my case I have a model order
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
Now I would like to give an administrator the possibility to create his own graphs through the AASM states. Therefore I created two additional models called OrderFlow and Transition where there order_flow has many transitions and order belongs_to order_flow.
No problem so far. Now I would like to give my admin the possibility to dynamically add existing transitions / events to an order_flow graph.
The problem now is, that I do not find any possibility to get a list of all events / transitions out of my order model. aasm_states_for_select seems to be the correct candidate, but I cannot call it on my order model.
Can anyone help?
Thx in advance. J.
ClassName.aasm.states.map(&:name)
will get you an Array of Symbols, which may be what you want. – Decontrol