gpt4 book ai didi

ruby-on-rails - 帮助解释 will_paginate 文档?

转载 作者:太空宇宙 更新时间:2023-11-03 17:28:16 25 4
gpt4 key购买 nike

试图了解 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”)

pageper_pagefinder 很简单。

total_entriescount -- 不理解“仅在手动计数条目时使用?”他们是否设想了这样一种场景:您运行单独的计数查询,然后将结果作为选项传递给 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com