Wice_gride не загружает все записи - PullRequest
0 голосов
/ 01 марта 2019

Я использую гем wice_grid в моем контроллере следующим образом:

  def providers
    @employee_certifications_grid = initialize_grid(EmployeeCertification, 
    include:[:employee,{employee: :orders}] , conditions: {status: "active", 
    employees: {status: "active", orders: {taker_id: current_company.id}}}, 
    order: 'expiration_date',  order_direction: 'asc', per_page: 15 )
  end

Страница успешно отрисована и внизу показывает, что правильное количество результатов (16).Но сетка показывает только 4 из них.Это не показывает все.Я обнаружил, что если я изменю параметр par_page на 54, я получу все результаты.Любые идеи о том, почему не работает?

Опять же, результат правильный, но он не показывает все записи в сетке.

app/views/providers.html.erb   

<section class="section">
  <div class="columns is-centered">
    <div class="column">
      <%= grid(@employee_certifications_grid) do |g|

        g.column name: 'Colaborador', attribute: 'nome', assoc: :employee, filter: false do |employee_certification|
          employee_certification.employee.nome
        end

        g.column name: 'Documento', attribute: 'name', assoc: :certification, filter: false do |employee_certification|
          employee_certification.certification.name
        end

        g.column name: 'Descição', attribute: 'title', assoc: :certification, filter: false do |employee_certification|
          employee_certification.certification.title
        end

        g.column name: 'Arquivo', filter: false do |employee_certification|
          link_to employee_certification.document.filename, employee_certification.document, target: :_blank 
        end

        g.column name: 'Validade', attribute: 'expiration_date', filter: false do |employee_certification|
          if employee_certification.expiration_date
            if employee_certification.expiration_date < employee_certification.employee.orders.active.minimum(:due)
              [employee_certification.expiration_date.strftime("%d/%m/%Y"), {style: 'background-color: rgb(255, 105, 104);'}]
            else
              employee_certification.expiration_date.strftime("%d/%m/%Y")
            end
          else
            "--"
          end
        end

        g.column name: 'Pedidos', filter: false do |employee_certification|
          link_to 'visualizar pedidos', root_path
        end


      end -%>
    </div>
  </div>
</section>
...