安装

gem 'will_paginate'

使用

#controller中方法
:page - current page, defaults to 1
:per_page - limit of items per page, defaults to 30
:total_entries - total number of items in the array, defaults to array.length (obviously)

#controller中使用案例
 @categories = @categories.page(params[:page] || 1).per_page(params[:per_page] || 10)
      .order(id: "desc")

results matching ""

    No results matching ""