Rails Will_paginate 对数组分页

首先引入will_paginate/array文件

config/application.rb

1
require 'will_paginate/array'
1
2
3
4
def index
  #如果数据不是 数组格式,需要转换为数组格式,别的就正常一样
  @servers = f.servers.all.to_a.paginate :page => params[:page], :order => 'created_at desc', :per_page => 5
end

Comments