在Gemfile中
gem 'will_paginate'
在您要分页的控制器中
class SomeController < ApplicationController
def index
@somethings = Model.all.paginate(page: params[:page], per_page: params[:per_page])
end
end
在你看来
<%= select_tag :per_page, options_for_select([5,10,20,50],params[:per_page].to_i),
:onchange => "if(this.value){window.location='?per_page='+this.value;}" %>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句