我正在使用带有Rails 2.3.11的will_paginate 2.3.25。
我希望我的page_entries_info
查看帮助者说“显示所有n [我自己的自定义措辞]”,而不是根据模型自动生成项目名称。
这样做的语法是什么?
答案 0 :(得分:3)
设置您的翻译yaml文件,以包含您在分页时要调用该模型的内容。
阅读本文档后:https://github.com/mislav/will_paginate/wiki/I18n
en:
will_paginate:
models:
line_item:
zero: line items
one: line item
few: line items
other: line items
或者对于“只需一次解决方案”,您可以使用page_entries_info
来自RDoc:
page_entries_info(collection, options = {})
使用显示的数量与总条目数量呈现有用的消息。您可以将此作为您自己的类似帮助者的蓝图。
<%= page_entries_info @posts %>
#-> Displaying posts 6 - 10 of 26 in total
默认情况下,消息将使用集合中对象的人性化类名称:例如,ProjectType模型的“项目类型”。使用:entry_name参数覆盖它:
<%= page_entries_info @posts, :entry_name => 'item' %>
#-> Displaying items 6 - 10 of 26 in total
答案 1 :(得分:2)
使用:entry_name
参数。
= page_entries_info @posts, :entry_name => 'item'
#-> Displaying items 6 - 10 of 26 in total