获取 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的东西:
Something like:
只是补充一下(因为我一直在寻找这个答案,并且我总是回到此页面),如果您尝试列出给定状态机的状态,请尝试以下操作:
Just to add to this (because I'm constantly searching for this answer, and I always come back to this page), if you are trying to list the states for a giving state machine, try this:
如果您以不同的方式命名您的状态字段,例如publish_status
If you name your state field differently , such as publish_status