2

I'm using will_paginate 2.3.25 with Rails 2.3.11.

I'd like my page_entries_info view helper to say "Displaying all n [my own custom wording]s" instead of auto-generating the item name based on the model.

What is the syntax to make it do that?

Ethan
  • 57,819
  • 63
  • 187
  • 237

2 Answers2

3

Set up your translation yaml file to include what you want to call that model when it is being paginated.

After reading this documentation: 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

Or for a "just this once solution" you can use page_entries_info

From the RDoc:

page_entries_info(collection, options = {})

Renders a helpful message with numbers of displayed vs. total entries. You can use this as a blueprint for your own, similar helpers.

  <%= page_entries_info @posts %>
  #-> Displaying posts 6 - 10 of 26 in total

By default, the message will use the humanized class name of objects in collection: for instance, "project types" for ProjectType models. Override this with the :entry_name parameter:

  <%= page_entries_info @posts, :entry_name => 'item' %>
  #-> Displaying items 6 - 10 of 26 in total
shaheenery
  • 8,457
  • 2
  • 17
  • 14
2

Use the :entry_name parameter.

= page_entries_info @posts, :entry_name => 'item'
#-> Displaying items 6 - 10 of 26 in total
Ethan
  • 57,819
  • 63
  • 187
  • 237