Skip to content

Instantly share code, notes, and snippets.

@maier-stefan
Last active August 29, 2015 14:06
Show Gist options
  • Save maier-stefan/9aaa92bf0cfce304b254 to your computer and use it in GitHub Desktop.
Save maier-stefan/9aaa92bf0cfce304b254 to your computer and use it in GitHub Desktop.
Collection Select
I have a multiselect with checkboxes:
<%= f.label :Category, :class => 'control-label' %>
<% Category.all.each do |category| -%>
<div>
<%= check_box_tag :category_ids, category.id, @job.categories.include?(category), :name => 'job[category_ids][]' %>
<%= label_tag :category_ids, category.name %>
</div>
<% end %>
I want to build a multiple collection Select like this
<div class="from-goup">
<%= f.label :category, :class => 'control-label' %><div class="controls">
<%= f.collection_select :category_ids, Category.all, :id, :name, { :selected => @job.categories }, { :multiple => true, :name => 'job[category_ids][]' }, :class => 'form-control' %>
</div>
</div>
Error: wrong number of arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment