Reputation:
i have written the f.select helper for this code
<select>
<option>abc</option>
<option>def</option>
<option selected>ghi</option>
</select>
<%= f.select(:xFields, ['abc', 'def', 'ghi]) %>
How do i make option 'ghi' selected as default?
Upvotes: 0
Views: 412
Reputation: 10997
edit
try this:
<%= f.select options_for_select(:xFields, ['abc', 'def', 'ghi'], 'ghi') %>
the following should work
<%= f.select(:xFields, [['ghi'], 'abc', 'def']) %>
based on Rails 3: f.select - options_for_select
Upvotes: 1
Reputation:
This is working
<%= f.select(:xFields, options_for_select( ['abc', 'def', 'ghi'], 'ghi')) %>
Upvotes: 0