문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top