Multiple select box is not working in rails

会有一股神秘感。 提交于 2019-12-06 04:45:15
 <select name="video[]" multiple="multiple" id="form-field-select-2" class="form-control">
 <%video.each do |option|%>
 <option><%=option%> </option>
 <%end%>
 </select>

You need to make sure that you are sending an array of answers by changing the name to video[]

You can do this with select_tag too

<%= select_tag 'video', options_from_collection_for_select(Video.all,"id","name"),  :multiple => true, class: 'form-control'%>

For more details,see this API

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!