I have a Person table in my database and I have a column named person_type. I don’t want a database model for person_type as it will always be either “Volunteer” or “Participant”. Where would I create a static array to hold these values and how would I bind that array to the Ruby on Rails select helper? Would it be best to just create a select helper?
Thanks!
The simplest way to implement this is by having a constant in your Person model:
which you can then access using the select helper:
If you need to consider i18n, it only needs a few slight modifications.
Given these entries in your i18n files:
You can update your model and view thus:
This will give you the HTML you’re after: