title: Rails form_tag and check_box_tag array for collection of selected objects
body: <p>Long time lurker but haven't posted yet. Despite hours of debugging I can't seem to figure out why my check_box_tag won't pass an array. Essentially I would like the check box behaviour to allow the user to select multiple records and then use a button to either discontinue or refill the record. </p>
  
  <p>View: </p>
  
  <pre><code>&lt;% @medications.each do |medication| %&gt;     
    &lt;div class="small-4 columns three-column"&gt;    
      &lt;%= link_to medication.drug_name, edit_medication_path(medication), remote: true  %&gt;            
    &lt;/div&gt;
    &lt;div class="small-3 columns three-column"&gt;
      &lt;%= link_to medication.duration, edit_medication_path(medication), remote: true %&gt;
    &lt;/div&gt;
    &lt;div class="small-3 columns three-column"&gt;
      &lt;%= link_to medication.duration_unit, edit_medication_path(medication), remote: true %&gt;
    &lt;/div&gt;
    &lt;div class="small-2 columns three-column"&gt; 
      &lt;%= form_tag(medication_select_path, method: 'put', :id =&gt; 'medication-select') do %&gt;
        &lt;%= check_box_tag "medications[]", medication.id  -%&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  
  &lt;div class="small-6 columns"&gt;
    &lt;%= submit_tag "Discontinue", :type =&gt; 'submit', :class =&gt; 'hollow alert button', :form =&gt; 'medication-select', :value =&gt; 'Discontinue', method: 'put' %&gt;
  &lt;/div&gt;
  &lt;div class="small-6 columns"&gt;
    &lt;%= submit_tag "Refill", :type =&gt; 'submit', :class =&gt; 'hollow create button', :form =&gt; 'medication-select', :value =&gt; 'Refill', method: 'put' %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>@selected_meds = Medication.find(params[:medications])
  </code></pre>
  
  <p>When I look at terminal after pressing the submit button I get an output with only the first medication.id listed in params despite selecting 4 records. </p>
  
  <p>Terminal: </p>
  
  <pre><code>Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"aNWTazi45CLxMA", "medications"=&gt;["44"], "commit"=&gt;"Discontinue"}
  </code></pre>
  
  <p>Also my output HTML appears to be correct when viewing source: </p>
  
  <pre><code>&lt;form id="medication-select" action="/medication_select" accept-charset="UTF-8" method="post"&gt;&lt;input name="utf8" type="hidden" value="&amp;#x2713;" /&gt;&lt;input type="hidden" name="_method" value="put" /&gt;&lt;input type="hidden" name="authenticity_token" value="DpJ8" /&gt;
  &lt;input type="checkbox" name="medication_id[]" id="medication_id_" value="44" /&gt;
  </code></pre>
  
  <p> </p>
  
  <p>I've tried multiple sources (and copied the code as clearly as possible) but still have been unable to get an array coming up in params ids. </p>
  
  <p><a href="http://railscasts.com/episodes/165-edit-multiple?view=asciicast" rel="nofollow">http://railscasts.com/episodes/165-edit-multiple?view=asciicast</a>
  <a href="http://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag" rel="nofollow">http://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag</a></p>
  
  <p>As expected from the terminal output I'm getting the expected changes to medication with id=44 but if I check medication with ids of 44, 46, 50 it only performs the controller action on the first checked id. </p>
  
  <p>The only thing I can think of is that maybe splitting up my submit buttons and my form_tag (but then referencing them with the html5 form tag) is changing the behaviour somehow? Thanks in advance, I've been pulling out my hair on this one. </p>
  
  <p>EDIT: Noted that when I select a single check box that is not the first box listed (for example, if the second check box has a id of 46) no id is passed into params. So I think this narrows down the issue to the check_box_tag or my form_tag, however, I still can't find why this isn't working, especially as the source code all appears correct in the browser).</p>