instance method
apply_inflections
Ruby on Rails 7.2.3
Since v3.2.22.5 PrivateSignature
apply_inflections(word, rules, locale = :en)
Applies inflection rules for singularize and pluralize.
If passed an optional locale parameter, the uncountables will be found for that locale.
apply_inflections('post', inflections.plurals, :en) # => "posts" apply_inflections('posts', inflections.singulars, :en) # => "post"
Parameters
-
wordreq -
rulesreq -
localeopt = :en
Source
# File activesupport/lib/active_support/inflector/methods.rb, line 376
def apply_inflections(word, rules, locale = :en)
result = word.to_s.dup
if word.empty? || inflections(locale).uncountables.uncountable?(result)
result
else
rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
result
end
end
Defined in activesupport/lib/active_support/inflector/methods.rb line 376
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Inflector