<%= f.select :club_type, Club::CLUB_TYPES, :prompt => "Select a Club
Type" %>
This works fine for getting data into the database.
My question: Is there a helper to get the display value back from the
database? If not, could somebody show me how to correct the following
to get the display value rather than the stored value.
...as long as there's no need for clubtypes to be displayed in any
particular order (arrays are returned in order, hashs aren't
necessarily)
For the minuscule amount of extra effort involved, create a model for
club types, seed it, and give it a "position" column if you want to
manage the order (or just put an :order clause on your default
finder).
Then use ClubType.all or named scopes for more functionality ...
Your clubs can change their club_type text column into a club_type_id
integer and add a belongs_to relationship, allowing you to do nice
easy queries, leverage Rails' functionality, and get rid of those
"magic" array/hash variables.
Sometimes things that seem like shortcuts (like using an array for
some "static" data) can quickly turn into dead ends. The framework
does all the hard work for you, so you might as well use it.