will_paginate API docs: https://github.com/mislav/will_paginate/wiki/API-documentation
Short answer
You can specify the model parameter as a string that will be correctly pluralized.
page_entries_info @contracts, :model => 'contract'
Longer answer
will_paginate docs suggests that you use the i18n engine to configure output. It's kind of a pain from AFAICT, you have to write out a single and multiple form for all your models in config/locales/*.yml (for example, en.yml), and the syntax %{foo} not like ERB, but just placeholders, therefore, you cannot do things like %{foo.downcase} .
If you write your assistant, you get full control over the exit. For instance:
def my_page_info(collection) model_class = collection.first.class if model_class.respond_to? :model_name model = model_class.model_name.human.downcase models = model.pluralize if collection.total_entries == 0 "No #{models} found." elsif collection.total_entries == 1 "Found one #{model}." elsif collection.total_pages == 1 "Displaying all #{collection.total_entries} #{models}" else "Displaying #{models} #{collection.offset + 1} " + "to #{collection.offset + collection.length} " + "of #{number_with_delimiter collection.total_entries} in total" end end end
Steve source share