如何在我的下拉框中設置id屬性?在Rails窗體選擇框中設置HTML id屬性
這裏是我的表格有問題的部分:
<%= f.fields_for :items do |builder| %>
<%= builder.label :description %><br />
<%= builder.text_field :description %><br />
<%= builder.label :material %><br />
<%= builder.select :material, @letters.map { |l| [l.material, l.material] }, :id => "material_field" %><br />
<%= builder.label :height %><br />
<%= builder.select :height, @letters.map { |l| [l.height, l.height] }, :id => "height_field" %><br />
<%= builder.label :thickness %><br />
<%= builder.select :thickness, @letters.map { |l| [l.thickness, l.thickness] }, :id => "thickness_field" %><br />
<%= builder.label :quantity %><br />
<%= builder.text_field :quantity, :id => "quantity_field" %>
<%= builder.link_to_remove "Remove this item" %>
<% end %>
的:ID =>「quantity_field」方法適用於文本字段,而不是爲選擇字段。查看HTML源代碼我得到材料文本框的「estimate_items_attributes_0_material」標識。
這是一個奇怪的不一致。任何幫助將不勝感激。
這是缺點的位置參數,而不是命名參數。 http://en.wikipedia.org/wiki/Connascence_(computer_programming) – Kris