<%= f.number_field :tov_id %>
并且该代码生成了这个html:
<input type="number" value="3" name="price[tov_id]" id="price_tov_id" />
此代码:
<%= select_tag(:tov_id, options_for_select(@tovs,2), :prompt => "select tov" ) %>
制作此html
<select name="tov_id" id="tov_id">
<option value="">select tov</option>
<option value="1">brake pad</option>
<option selected="selected" value="2" >nut</option>
<option value="3">bolt</option></select>
我们可以看到:option_to_select的第二个参数响应所选的选项 但是当我写这篇文章时:
<%= select_tag(:tov_id, options_for_select(@tovs , :tov_id ), :prompt => "Select tov" ) %>
没有任何选择出现:(
<select name="tov_id" id="tov_id"><option value="">Select tov</option><option value="1">brake pad</option>
<option value="2">nut</option>
<option value="3">bolt</option></select>
如何从以下值获取值:tov_id并将其放入options_for_select?