Q. What resource do readers recommend for referencing regarding best
practices for form construction in Rails?
I have the following situation: location_type of Locations may have one
of five (5) possible codes. Presently I have these codes listed in a
drop-down select constructed thusly:
<%= f.select :location_type, [ ['MAIN - Main Address', 'MAIN'], ['POST - Postal Delivery', 'POST'], ['DELV - Package Delivery', 'DELV'], ['SHIP - Package Shipping', 'SHIP'], ['OTHR - Other', 'OTHR'], ], :selected => 'MAIN', :size => 4 -%>
Should this instead be constructed so that the model, Locations, has
these virtual attributes:
valid_location_type= [ ['MAIN - Main Location','MAIN'], ['POST - Postal Delivery', 'POST'], ... ] default_location_type = 'MAIN'
and then the view could have this instead:
<%= f.select :location_type, @location.valid_location_type, :selected => @location.default_location_type, :size => 4
Would this even work?