我正在使用will_paginate gem
进行分页
这是我的代码:
allrecord2 = (w_post+w_like+w_shares).sort{|a,b| b.created_at <=> a.created_at }
@wallpostrecord=allrecord2.sort{|a,b| b.created_at <=> a.created_at }.group_by{|hase| hase.Pid}
@paginateData=@wallpostrecord.paginate(:page => params[:page], :per_page => 25)
答案 0 :(得分:1)
只需使用to_a
将哈希数据转换为数组。
将此行包含在控制器顶部:require 'will_paginate/array'
@paginateData=@wallpostrecord.to_a.paginate(:page => params[:page], :per_page => 25)