Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
371 views
in Technique[技术] by (71.8m points)

ruby on rails - get list of state_machine states

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Something like:

User.state_machine.states.map &:name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...