我正在尝试在 Rails 中创建一个多选列表框。我的视图代码是:
<div>
<%=nested_form_for(@allocation) do|builder|%>
<%=builder.label :song_id, "Pick a song" %>
<%=builder.select :song_id, options_for_select(
Song.all.collect {|s| [ [s.title, s.artist].join(" by "), s.id ] },
{ include_blank: true, multiple: true, size: 5 }) %>
<%=builder.submit "Add Song", class: "btn btn-large btn-primary" %>
<% end %>
</div>
目前我只有普通的单选框,但我想将其转换为多选。任何指针将不胜感激。提前致谢