Say I have an ActiveResource which has an schema with several attributes. One of the attributes is expected to have three values (defined by the API where the ActiveResource is talking to).

Since I am creating forms for this ActiveResource object, I want to know where should I store those three possible values? Imagine that in the form I want to show a drop down list.

有帮助吗?

解决方案

This answer in the Stackoverflow post has an ActiveRecord example for storing possible values in a separate class and then validating that an ActiveRecord attribute has one of those values: Enumeration in Ruby on rails

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top