In my view I have an option select and I want to have a default option
selected, and it won’t necessarily be the first one. I load the
form.select with an array, and I want the user’s previous choice to be
selected. I save their choice in a cookie, and I can of course pass
it into the view again, but how do I get it selected?
AWDwRv2 shows an example on the top of page 486, where this is
accomplished, but it doesn’t call out how it was done.
Any help would be appreciated.
Specific examples below…
Snippet of view:
<%= form.select(:carrier, CARRIERS ) %>
Snippet of controller:
@carrier = ‘AC’ # I’ve tried also setting to ‘Air Canada’.
CARRIERS is an array, of the form:
CARRIERS = [
[‘Air Canada’, ‘AC’],
[‘Alaska Airlines’, ‘AS’],
[‘Virgin Atlantic’, ‘VS’],