문제

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