【问题标题】:will_paginate render page countwill_paginate 渲染页数
【发布时间】:2021-07-11 11:48:11
【问题描述】:

我正在使用 will_paginate,我正在尝试实现转到页面。

但是,我似乎在渲染页数时遇到了问题,目前我有以下问题

<div class="nav-pagination-new">
  <%= will_paginate @contacts, previous_label: h('«'), next_label: h('»')  %>

  <% if @contacts.total_entries > 1 %>
    <label for="go-to-page" class="nav-title">Go to page
      <input type="text" id="go-to-page" class="nav-input form-input-sm" name="page"> / <%= @contacts.total_entries %>
    </label>
  <% end %>
</div>

我已经尝试过total_entrieslength,但显然这些都不会得到想要的结果,所以我错过了什么?

【问题讨论】:

    标签: ruby-on-rails ruby will-paginate


    【解决方案1】:

    你需要的是@contacts.total_pages

    【讨论】:

    • 是的,当您回答哈哈时,我将如何使用页面参数进行输入,以便用户可以转到该页面,即&lt;%= text_field_tag params[:page] %&gt;
    猜你喜欢
    • 2017-11-24
    • 1970-01-01
    • 1970-01-01
    • 2011-10-13
    • 2014-06-24
    • 2011-03-19
    • 1970-01-01
    • 2012-04-27
    • 2012-07-23
    相关资源
    最近更新 更多