How to pluralize “There is/are N object/objects”?
问题 Pluralizing a single word is simple: pluralize(@total_users, "user") But what if I want to print "There is/are N user/users": There are 0 users There is 1 user There are 2 users , i.e., how to pluralize a sentence ? 回答1: You can add a custom inflection for it. By default, Rails will add an inflections.rb to config/initializers . There you can add: ActiveSupport::Inflector.inflections do |inflect| inflect.irregular "is", "are" end You will then be able to use pluralize(@total_users, "is") to