title: Check boxes in table for form
body: <p>Ruby on Rails 4</p>
  
  <p>I want to fill a table with rows of Questions. Then have a checkbox as a column to select the Question to submit in my form. I have a collection_check_boxes, not sure how to put them in the table where the :question_ids will be selectable.</p>
  
  <p>The form:</p>
  
  <pre><code>&lt;%= form_for(@test) do |f| %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :name %&gt;&lt;br&gt;
      &lt;%= f.text_field :name %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :type %&gt;&lt;br&gt;
      &lt;%= f.text_field :type %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :question %&gt;&lt;br&gt;
      &lt;%= f.collection_check_boxes :question_ids, Question.all.to_a.collect, :id, :content, {class: "form-control input-lg"} %&gt;
    &lt;/div&gt;
  
    &lt;div id="container" style="width:1100px; margin-left: auto; margin-right: auto;"&gt;
    &lt;button type="button" class="reset"&gt;Reset Search&lt;/button&gt;
    &lt;table width="100%" class="tablesorter"&gt;
    &lt;thead&gt;
    &lt;tr&gt;
      &lt;th width="2%" class="filter-false"&gt;CHECKBOX Header&lt;/th&gt;
      &lt;th width="40%" data-placeholder="Search"&gt;Content&lt;/th&gt;
      &lt;th width="10%" data-placeholder="Search"&gt;Type&lt;/th&gt;
      &lt;th width="10%" data-placeholder="Search"&gt;Category&lt;/th&gt;
      &lt;th width="10%" data-placeholder="Search"&gt;Product&lt;/th&gt;
      &lt;th width="10%" data-placeholder="Search"&gt;User&lt;/th&gt;
      &lt;th width="8%" data-placeholder="Search"&gt;Active&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
  
  &lt;tbody&gt;
  &lt;%# f.Question.all. ? do |q| %&gt;
  &lt;% @questions.each do |q| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;% q.check_box_tag %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.content %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.question_type %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.category %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.Product.find(product_id).name %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.user_id %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= q.active %&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;% end %&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;br&gt;
  &lt;/div&gt;
  &lt;div class="actions"&gt;
    &lt;%= f.submit "Create Test", id: "commit" %&gt;
  &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>