使用 jquery 数据 gem 捕获复选框分页的参数

catch params of check box pagination using jquery datable gem

无法捕获剩余页面的 check_box 参数我只得到第一页参数请帮助我

我只能捕获提交页面参数

我的观点

 <table id="associations" class="table table-striped table-bordered ">
      <thead>
      <th>Check</th>
      <th>Logo</th>
      </thead>
      <tbody>
      <% @benefits.each do |benefit|%>
          <%@selected_benefits = AssocBenefit.where(:benefit_id=>benefit.id, :association_id => @association.id, :status => true).first%>
          <tr>
            <td>
              <%#= check_box_tag :car, :value => 2, :checked => (f.sex == 2) %>
              <%if @selected_benefits.present?%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id %>
                  <%= check_box_tag 'benefits[]', benefit.id, :checked => (benefit.id == @selected_benefits.id)%>
                  </td>
              <%else%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id %>
                  <%= check_box_tag 'benefits[]', benefit.id%></td>
              <%end%>
              <td><%= image_tag benefit.image(:thumb) %></td>
              <td><%= benefit.benefits_name%></td>

      <%end%>
      </tbody>
    </table> 

我的控制器

        def save_choose_benefits
   assoc_benefits = AssocBenefit.where.not(:benefit_id =>  params[:benefits]).all if params[:benefits1]
      assoc_benefits.delete_all
       unless params[:benefits].blank?

    params[:benefits].each do |d|
    ss= AssocBenefit.where(:benefit_id => d).first
    if ss.blank?
         assoc_benefits = AssocBenefit.new(:benefit_id => d ,:association_id => params[:association_id], :status=>"true")
      if assoc_benefits.valid?
        assoc_benefits.save
      end
      end
     end
      end
redirect_to associations_list_path ,:notice => "Successfully applied"

 end

这是我的脚本

       <script>
    $(document).ready(function()
       {
           $('#associations').dataTable();
       }
      );
    </script>

我安装了 gem jquery-datatables 和 jquery-turbolink 来传递参数但是没有运气传递第二页的参数等等。

请帮我解决这些问题

谢谢

    <table id="associations" class=" display table table-striped table-bordered ">
      <thead>
      <th>Check</th>

      <th>Logo</th>

      </thead>
      <tbody>
      <% @benefits.each do |benefit|%>

          <%@selected_benefits = AssocBenefit.where(:benefit_id=>benefit.id, :association_id => @association.id, :status => true).first%>
          <tr>
            <td>

              <%if @selected_benefits.present?%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id, :unchecked => (benefit.id != @selected_benefits.id) %>
                  <%= check_box_tag 'benefits[]', benefit.id, :checked => (benefit.id == @selected_benefits.id)  %>
                  </td>
              <%else%>
                  <%= hidden_field_tag 'benefits1[]', benefit.id %>
                  <%= check_box_tag 'benefits[]', benefit.id %></td>
              <%end%>

              <td><%= image_tag benefit.image(:thumb) %></td>
              </tr>
      <%end%>
      </tbody>
    </table>

    <%= submit_tag "Apply", :id=>"assoc_apply"%>

         <script>
          $(document).ready(function() {
              var table = $('#associations').DataTable({
              responsive: true,
              retrieve: true,
              sPaginationType: "full_numbers",
              bJQueryUI: true});

      $('#assoc_apply').click( function() {
          var data = table.$('input, select').serialize();
          var association_id = "<%=@association.id%>";
          window.location.href='/benefits/save_choose_benefits?' + data +"&association_id=" + association_id;
      } );
  } );