Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling event fails with Transitions::InvalidTransition although target state is valid #24

Closed
jensb opened this issue Mar 23, 2011 · 4 comments

Comments

@jensb
Copy link

jensb commented Mar 23, 2011

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!

@qoobaa
Copy link
Collaborator

qoobaa commented Mar 23, 2011

I'm not sure if it's a bug, but you can try to fix this behaviour to match your requirements.

@troessner
Copy link
Owner

@jensb Any updates on this?

@jensb
Copy link
Author

jensb commented Aug 12, 2011

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.

@troessner
Copy link
Owner

@jensb

I'll close this for now, please re-open it when you're able to reproduce it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants