For mongoid, you have to user will_paginate_mongoid. If that doesn't work, you can look at this cuestion here. Anyway, just adding will_paginate_mongoid gem to my Gemfile worked for me.
How to extend will_paginate for a rails gem with Mongoid
-
09-10-2022 - |
質問
need some help. I have been updating a gem for a rails forum software. It would usually require ActiveRecord but I have converted a majority of the gem to Mongoid.
Now here is where I need some help, I am attempting to use will_paginate's per_page method.
Here is the code provided.
if defined?(WillPaginate)
module WillPaginate
ActiveSupport.on_load :active_record do
module ActiveRecord
module RelationMethods
alias_method :per, :per_page
alias_method :num_pages, :total_pages
end
end
end
end
Now the problem is I am using Mongoid, and I am unsure exactly how I would convert this to mongoid. If someone could help me I would appreciate that.
Resources:
Mongoid- https://github.com/mongoid/mongoid
Will_paginate- https://github.com/mislav/will_paginate
Thanks in advanced!
解決
所属していません StackOverflow