I’m trying to make a multi select list box in Rails. My view code is:
<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>
At the moment I just have the normal single selectbox but I want to convert this to a multiselect. Any pointers would be much appreciated. Thanks in advance
This seems to have worked in my case: