Search code examples
ruby-on-rails-3activeresource

Rails: Where to store possible values of an attribute in ActiveResource


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.


Solution

  • 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