使用mongo db将will_paginate与ruby分页

时间:2016-03-31 18:05:57

标签: ruby-on-rails mongoid will-paginate

我阅读了will_paginate教程,结果是

undefined method `total_pages' for #<Mongoid::Criteria:0x007f7c09428d80>
class   ServicesController < ApplicationController
    def index
        @services = Service.all.paginate(page: params[:page], per_page: 5)
        @organs = Admin::Organ.all

    end

    def show
        @service = Service.where(permalink: params[:permalink]).first       
    end
end
<%= will_paginate @services %>

是否有人对此错误有所了解?

1 个答案:

答案 0 :(得分:0)

你可以在索引方法中做这样的改变吗

def index
  @organs = Admin::Organ.all
  @services = Service.all.paginate(page: params[:page], per_page: 5)
end