1

I've got a form with the following selection list:

<th>Unit Size</th>

   <td><%= f.select :unit_size, options_for_select((1..@foo.bar.bar_type.usize)), {selected: @foo.unit_size} %></td>

No matter what foo.unit_size is in the DB, the form always has '1' selected in the dropdown.

4

1 回答 1

2

Selected option should be passed to #options_for_select, not to #select as "selected" key :

f.select :unit_size, options_for_select((1..@foo.bar.bar_type.usize), @foo.unit_size)
于 2013-09-12T16:51:38.367 回答