You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With AASM, I was using @foo.aasm_events_for_current_state and @foo.aasm_events_for_state(the_state) to verify whether a specific event could be called before actually calling it. This was necessary as a validation because I have an attr_accessible :event which is used in forms (select field) to change state.
With Transitions, I tried using self.class.state_machines[:default].events_for(self.state.to_sym) instead of events_for_current_state, and it works and contains the event I want to call. However, when I subsequently call the event using self.send("#{self.event}"), I get a InvalidTransition exception.
I noticed that Transitions does not normalize state names to "string" or :symbol form, i.e. when I set the state using strings, but compare it using symbols, or vice versa, comparison fails.
Is this a known bug? Or else, how would I solve this task using Transitions?
Thanks!
The text was updated successfully, but these errors were encountered:
I cannot reproduce. I think it was a before_filter that returned false, that is why I got no validation errors but the transition failed. But I'll dig through my SVN logs and try to find the changeset.
With AASM, I was using
@foo.aasm_events_for_current_state
and@foo.aasm_events_for_state(the_state)
to verify whether a specific event could be called before actually calling it. This was necessary as a validation because I have anattr_accessible :event
which is used in forms (select field) to change state.With Transitions, I tried using
self.class.state_machines[:default].events_for(self.state.to_sym)
instead ofevents_for_current_state
, and it works and contains the event I want to call. However, when I subsequently call the event usingself.send("#{self.event}")
, I get a InvalidTransition exception.I noticed that Transitions does not normalize state names to "string" or :symbol form, i.e. when I set the state using strings, but compare it using symbols, or vice versa, comparison fails.
Is this a known bug? Or else, how would I solve this task using Transitions?
Thanks!
The text was updated successfully, but these errors were encountered: