I have a select box in rails. When editing the records, I want the previously selcted items to be highlighted.
I have
<div class="field">
<td><%= f.label :keywords %>(Use Control-Click to select multiple keywords)</td>
<td> <%= f.select :keywords,
options_for_select(@keywords,
:selected => @keywords),
{:include_blank => false},
{:multiple => true, :size =>10} %>
</div>
I tried a couple of variations on the :selected => statement above but can't get what I want.
What I'm looking for is When a user edits a record, the f.select will have the selections that are in the database pre selected.
I do see a "Gotcha" here in that even if the items are pre selected, if the user clicks on any item without a Control-click, then the pre selected items are lost.
-------- update-----------
form for
<%= form_for @bedsheet_line, :html =>
{ :class => 'form-horizontal', multipart: true} do |f| %>