get list of state_machine states

phil picture phil · Nov 9, 2010 · Viewed 10k times · Source

We are using state_machine ( https://github.com/pluginaweek/state_machine ) in a project and would like to offer a form with a select that lets us choose a state. (this is for searching, not for setting). I can't seem to find a way to list out all the possible states? Surely there should be an automatic way of doing this, not having to hard-code a list of text somewhere. Thanks!

Answer

jwarchol picture jwarchol · Nov 9, 2010

Something like:

User.state_machine.states.map &:name