试图了解 will_paginate 的 paginate
的选项方法:
:page — REQUIRED, but defaults to 1 if false or nil
:per_page — defaults to CurrentModel.per_page (which is 30 if not overridden)
:total_entries — use only if you manually count total entries
:count — additional options that are passed on to count
:finder — name of the ActiveRecord finder used (default: “find”)
page
、per_page
和 finder
很简单。
total_entries
和 count
-- 不理解“仅在手动计数条目时使用?”他们是否设想了这样一种场景:您运行单独的计数查询,然后将结果作为选项传递给 paginate
?在什么情况下您会这样做?
“传递给计数的附加选项”——有哪些选项可用? “传递”到 ??? 的 count
方法
最佳答案
默认情况下,will_paginate 使用计数(来自 ActiveRecord::Calculations )来计算您正在分页的对象总数。但如果您知道得更多,或者直接计数不起作用,您可以自己计算并提供 :total_entries。
:count 参数用于 ActiveRecord::Calculations#count 方法的额外参数,如 :distinct。您可以查看文档以获取完整列表。
关于ruby-on-rails - 帮助解释 will_paginate 文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1082927/