pluralize without count number in rails 4 -
i building blog app. i'd able pluralize word "article" if more 1 "post" "published."
like so: available articles or available article
this have....
available <%= pluralize @posts.published, "article" %>:
i've tried
available <%= pluralize @posts.published.count, "article" %>:
and works...but don't want number. shouldn't read available 5 articles....it should have no number.
i have been looking answer myself , wasn't satisfied of existing ones. here's tidiest solution found:
available <%= "article".pluralize(@posts.published.count) %>:
documentation here. relevant bits:
returns plural form of word in string.
if optional parameter count specified, singular form returned if count == 1. other value of count plural returned. 'post'.pluralize # => "posts" 'apple'.pluralize(1) # => "apple" 'apple'.pluralize(2) # => "apples"
Comments
Post a Comment