instance method
apply_inflections
Ruby on Rails 4.0.13
Since v3.2.22.5 PrivateSignature
apply_inflections(word, rules)
Applies inflection rules for singularize and pluralize.
apply_inflections('post', inflections.plurals) # => "posts" apply_inflections('posts', inflections.singulars) # => "post"
Parameters
-
wordreq -
rulesreq
Source
# File activesupport/lib/active_support/inflector/methods.rb, line 331
def apply_inflections(word, rules)
result = word.to_s.dup
if word.empty? || inflections.uncountables.include?(result.downcase[/\b\w+\Z/])
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 331
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::Inflector