rails 分页 采用的是will_paginate,具体使用方式下面介绍,
打开gemfile
gem "will_paginate"
保存,然后在命令行执行bundle install
安装插件
在contorller的列表方法里
@products = Product.all.paginate :page => params[:page]||1, :per_page => 1
#:per_page 每页多少条数据
在erb页面里使用
<%= will_paginate @products, :prev_label => '上一页',
:next_label => '下一页' %>
运行一下试试看,完成分页操作,。