module ActiveSupport::Inflector

def apply_inflections(word, rules)

apply_inflections('posts', inflections.singulars) # => "post"
apply_inflections('post', inflections.plurals) # => "posts"

Applies inflection rules for +singularize+ and +pluralize+.
def apply_inflections(word, rules)
  result = word.to_s.dup
  if word.empty? || inflections.uncountables.uncountable?(result)
    result
  else
    rules.each { |(rule, replacement)| break if result.sub!(rule, replacement) }
    result
  end
end