我在form_for中使用了collection_select,但是浏览器中没有显示选项(空的选择框),但出现在调试器视图中。 (这发生在Chrome和IE10中)。Ruby on Rails - form_for collection_select选项不可见
查看:
<%= form_for(@lot) do |f| %>
<%= f.label :client_id, "Client" %>
<%= f.select :client_id, collection_select(:lot, :client_id, Client.all, :id, :org, :include_blank => "Please select") %>
渲染页面的源代码:
<label for="lot_client_id">Client</label>
<select id="lot_client_id" name="lot[client_id]"></select>
<option value="">Please select</option>
<option selected="selected" value="1">Client 1</option>
<option value="2">client 2</option>
控制器:
def new
@lot = Lot.new(:client_id => 1)
end
任何有识之士将不胜感激,谢谢,
谢谢,这部分解决了它。作为@lot的形式,我还需要删除:使其成为<%= f.collection_select(:client_id,Client.all,:id,:org)%>: – user2732663