What's the Rails way to handle singular/plural possibility?
ActionView::Helpers::TextHelper::pluralize(count, singular, plural = nil)
Attempts to pluralize the
singular
word unlesscount
is 1. Ifplural
is supplied, it will use that when count is > 1, otherwise it will use the Inflector to determine the plural form
Examples:
pluralize(1, 'person')
# => 1 person
pluralize(2, 'person')
# => 2 people
pluralize(3, 'person', 'users')
# => 3 users
pluralize(0, 'person')
# => 0 people
In Rails 5
'person'.pluralize(2)
# => people