网站 index 页面信息过多,分页方式可提升浏览体验,使用 gem 'will_paginate'
可实现
参考链接:
第一步
文件 Gemfile 加载相关的两个 gem
gem 'will_paginate'
gem 'will_paginate-bootstrap'
第二步
终端 bundle install
重启 rails s
第三步
修改 Controller 文件
def index
@notices = Notice.all.paginate(:page => params[:page], :per_page => 10)
end
第四步
修改 View 文件
<div class="text-center">
<%= will_paginate @notices, renderer: BootstrapPagination::Rails %>
</div>