instance method
singularize
Ruby on Rails 6.0.6
Since v2.2.3Signature
singularize(word, locale = :en)
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.
singularize('posts') # => "post" singularize('octopi') # => "octopus" singularize('sheep') # => "sheep" singularize('word') # => "word" singularize('CamelOctopi') # => "CamelOctopus" singularize('leyes', :es) # => "ley"
Parameters
-
wordreq -
localeopt = :en
Source
# File activesupport/lib/active_support/inflector/methods.rb, line 48
def singularize(word, locale = :en)
apply_inflections(word, inflections(locale).singulars, locale)
end
Defined in activesupport/lib/active_support/inflector/methods.rb line 48
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Inflector