pluralizeヘルパー
英語専用のテキストヘルパー。
最初の引数に整数があると、それに基づいて2番目の引数である英単語が複数形に変化したものが渡される。
サンプルコード
>> pluralize(2, "woman")
=> "2 women"
>> pluralize(3, "erratum")
=> "3 errata"
実施例
<%= pluralize(@user.errors.count, "error") %>
このコードだと"0 errors"、"1 error"、"2 errors"などのように、エラーの数によって活用される単語が変わってきます。"1 errors" のような英語の文法に合わない文字列を避けることができます