title: Select All/Deselect All checkboxes in a page
body: <p>I've looked at <a href="http://railsforum.com/viewtopic.php?id=2151" rel="nofollow noreferrer">this</a> which seems to have no effect on my code.
  I've tried <a href="https://stackoverflow.com/questions/888173/select-all-checkboxes">this</a> which seems to only affect the first checkbox, but doesn't uncheck the checkbox when i click it again anyway....
  I've also seen some other ways of doing it that I'm not certain are entirely Rails-esque (or whatever the term should be).</p>
  
  <p>So, could someone please point me in the right direction?</p>
  
  <p>Here is my view:</p>
  
  <pre><code>&lt;%= render 'admin/distributions/head' %&gt;
  &lt;% title 'Workflow' %&gt;
  
  
  &lt;%= form_for @search, :url =&gt; url_for(:controller =&gt; params[:controller], :action =&gt; params[:action]), :html =&gt; {id =&gt; "distribution_workflow",:method =&gt; :get} do |f| %&gt;
  
    &lt;div class="opportunity-block yellow"&gt;
  
      &lt;div class="form-block mrl mbm"&gt;
        &lt;%= f.label :created_at_gt, "Created at &gt;" %&gt;
        &lt;%= f.text_field :created_at_gt, :class =&gt; "js-db-date-picker" %&gt;
      &lt;/div&gt;
  
      &lt;div class="form-block mrl mbm"&gt;
        &lt;%= f.label :created_at_lte, "Created at &lt;=" %&gt;
        &lt;%= f.text_field :created_at_lte, :class =&gt; "js-db-date-picker" %&gt;
      &lt;/div&gt;
  
      &lt;div class="form-block mrl mbm mtm"&gt;
        &lt;%= f.label :status_equal, "Status" %&gt;
        &lt;%= f.select :status_equal, %w(delivered no_success already_registered qa_complete success follow_up), :include_blank =&gt; " " %&gt;
      &lt;/div&gt;
  
      &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;%= submit_tag 'Apply Filter', :class =&gt; "input-button dark unit-right mrl" %&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;% end  %&gt;
  
  
  &lt;%= form_tag edit_multiple_admin_distributions_workflows_path , :id =&gt; "workflow_form" do %&gt;
  &lt;%= submit_tag "Edit Selected" %&gt;
    &lt;table class="standard-grid"&gt; 
      &lt;tr&gt; 
        &lt;th class="first"&gt; &lt;/th&gt;
        &lt;th&gt;ID&lt;/th&gt;
        &lt;th&gt;Customer&lt;/th&gt;
        &lt;th&gt;Resume URL&lt;/th&gt;
        &lt;th&gt;Partner&lt;/th&gt;
        &lt;th&gt;Status&lt;/th&gt;
        &lt;th&gt;Assigned To&lt;/th&gt;
        &lt;th&gt;Comments&lt;/th&gt;
      &lt;/tr&gt;
      &lt;% @report.each do |distribution| %&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;%= check_box_tag "distribution_ids[]", distribution.id %&gt;&lt;/td&gt;
          &lt;td&gt;
            &lt;%= distribution.owner.id %&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;%=link_to distribution.owner.full_name, "mailto:#{distribution.owner.email}" %&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;a href=&lt;% UrlService.download_blob_url(distribution.resume) %&gt;&gt;Resume URL&lt;/a&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;%=link_to distribution.matching_profile.partner.title,  "mailto:#{distribution.matching_profile.partner.email}" %&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;%= distribution.status %&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;%= distribution.assignee_id ? User.find(distribution.assignee_id).full_name : " " %&gt;
          &lt;/td&gt;
          &lt;td&gt;
            &lt;%= distribution.comments %&gt;
          &lt;/td&gt;
        &lt;/tr&gt;
      &lt;% end %&gt;
    &lt;/table&gt;
  &lt;% end %&gt;
  </code></pre>