0
class Service 
  include Mongoid::Document 
  include Mongoid::Search 
  include Mongoid::Pagination 
  field :name, type: String
end

My controller

@services = Service.where(active: true).per_page(10)

the gem mongoid-pagination

The index.html.erb

<% paginate @services %>

The problem

undefined method `total_pages' for

The documents https://github.com/ajsharp/mongoid-pagination

I need to solve the problem with paginate.

B25Dec
  • 2,301
  • 5
  • 31
  • 54

1 Answers1

0

Best answer I've found here: https://stackoverflow.com/a/48287946/1678507

kaminari-mongoid was released in 2016, and is currently maintained.

https://github.com/kaminari/kaminari-mongoid

All the goodness of Kaminiari for Mongoid, including appropriate handling of Mongoid::Criteria results, which was possibly the cause of the OP's error

And in context of OP's question:

Movie.page(2).total_pages #=> 1
Dishcandanty
  • 411
  • 1
  • 6
  • 13