![](/img/trans.png)
[英]How to implement Ajax with will_paginate gem on Ruby on Rails
[英]How to extend will_paginate for a rails gem with Mongoid
需要一些幫助。 我一直在更新Rails論壇軟件的gem。 通常需要ActiveRecord,但我已將大多數寶石轉換為Mongoid。
現在這是我需要幫助的地方,我正在嘗試使用will_paginate的per_page方法。
這是提供的代碼。
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
現在的問題是我正在使用Mongoid,並且我不確定如何將其轉換為Mongoid。 如果有人可以幫助我,我將不勝感激。
資源:
Mongoid- https://github.com/mongoid/mongoid
Will_paginate- https://github.com/mislav/will_paginate
提前致謝!
對於蒙古包,您必須使用will_paginate_mongoid。 如果那不起作用,您可以在這里查看此提示。 無論如何,僅將will_paginate_mongoid gem添加到我的Gemfile中對我來說是有效的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.