Reputation: 6317
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.
Upvotes: 34
Views: 8475
Reputation: 4230
aasm now supports transitions without any from
specified, which will allow transitioning from any state.
aasm_event :publish do
transitions to: :publish # from ANY
end
(bragging rights: I added this feature because I needed it)
Upvotes: 86
Reputation: 13393
You can get the states via the aasm_states
class method, provided they have already been defined earlier in the code.
aasm_event :publish do
transitions :to => :publish, :from => aasm_states.map(&:name)
end
Upvotes: 6