0

I have this problem

undefined method `total_pages' for
# <Mongoid::Criteria:0x00000002651d80>

# controller
@services = Service.paginate(:page => params[:page], :per_page => 3)

# view
<% paginate @services %>

The mongo doesn't return the object.

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59

2 Answers2

2

In kaminari, you have to use below syntax

 Service.page(params[:page].to_i).per(3)

instead of

 Service.paginate(:page => params[:page], :per_page => 3)

This is the syntax of will_paginate

Sukanta
  • 585
  • 3
  • 6
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

<% pagination @services %>
Erro

undefined method `total_pages' for #<Mongoid::Criteria:0x00000002651d80>

was this