Ruby on Rails: how to check pluralized and single form of names Ruby on Rails: how to check pluralized and single form of names ruby-on-rails ruby-on-rails

Ruby on Rails: how to check pluralized and single form of names


You can do this in the rails console.

$ "anonymous".pluralize=> "anonymous" 

or another example where the plural word is different.

$ "cookie".pluralize=> "cookies" 


pluralize(count, singular, plural = nil) public

Attempts to pluralize the singular word unless count is 1. If plural 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 personpluralize(2, 'person')# => 2 peoplepluralize(0, 'person')# => 0 people

for you

"anonymous".pluralize


I'd just rename your model. Save yourself the pain and future debugging and just avoid this potential headache. You could use "Anonymouse" with plural "Anonymouses". Or think up a more clever name.