获取 state_machine 状态列表 [英] get list of state_machine states

查看:53
本文介绍了获取 state_machine 状态列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在一个项目中使用 state_machine ( https://github.com/pluginaweek/state_machine )并想提供一个带有选择的表单,让我们选择一个状态.(这是用于搜索,而不是用于设置).我似乎找不到列出所有可能状态的方法?当然应该有一种自动的方式来做到这一点,而不必在某处硬编码文本列表.谢谢!

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!

推荐答案

类似:

User.state_machine.states.map &:name

这篇关于获取 state_machine 状态列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆