instance method
singularize
Ruby on Rails 4.2.9
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.
'posts'.singularize # => "post" 'octopi'.singularize # => "octopus" 'sheep'.singularize # => "sheep" 'word'.singularize # => "word" 'CamelOctopi'.singularize # => "CamelOctopus" 'leyes'.singularize(: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)
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