我有这个问题
undefined method `total_pages' for #<Mongoid::Criteria:0x00000002651d80>
&#13;
@services = Service.paginate(:page => params[:page], :per_page => 3)
&#13;
视图
<% paginate @services %>
&#13;
mongo不会返回对象。
答案 0 :(得分:0)
的Controler
class ServicesController < ApplicationController
def index
#@services = Service.order(name: :asc)
@organs = Admin::Organ.all
@services = Service.paginate(:page => params[:page], :per_page => 3)
end
end
&#13;
<% pagination @services %>
&#13;
undefined method `total_pages' for #<Mongoid::Criteria:0x00000002651d80>
&#13;
是这个
答案 1 :(得分:0)
在kaminari,你必须 使用以下语法
Service.page(params[:page].to_i).per(3)
而不是
Service.paginate(:page => params[:page], :per_page => 3)
这是will_paginate
的语法