singularize

singularize(word, locale = :en)
Instance Public methods

The reverse of pluralize, returns the singular form of a word in a string.

If passed an optional locale parameter, the word will be singularized using rules defined for that language. By default, this parameter is set to :en.

1
2
3
4
5
6
'posts'.singularize            # => "post"
'octopi'.singularize           # => "octopus"
'sheep'.singularize            # => "sheep"
'word'.singularize             # => "word"
'CamelOctopi'.singularize      # => "CamelOctopus"
'leyes'.singularize(:es)       # => "ley"
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.