2

I generally do something like this, but if feels nasty and not very dry:

-if minutes == 1
  added #{minutes} minute ago
-else
  added #{minutes} minutes ago
superluminary
  • 47,086
  • 25
  • 151
  • 148

2 Answers2

5
<%= pluralize(minutes, "minute") %> if you're in a view.
cdesrosiers
  • 8,862
  • 2
  • 28
  • 33
1

See http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-pluralize

"added #{ pluralize(minutes, "minute") } ago"

There is an optional third argument that you can add if the plural version is non-standard and rails can't figure it out. For example (from the docs):

pluralize(3, 'person', 'users')
Justin
  • 1,203
  • 8
  • 15