Skip to content

Instantly share code, notes, and snippets.

@davidcelis
Created July 19, 2012 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcelis/3145080 to your computer and use it in GitHub Desktop.
Save davidcelis/3145080 to your computer and use it in GitHub Desktop.
Better Rails Inflections
ActiveSupport::Inflector.inflections do |inflect|
inflect.clear
inflect.plural(/$/, 's')
inflect.plural(/[sxz]|[cs]h$/i, 'es')
inflect.plural(/[^aeiouy]o/i, 'es')
inflect.plural(/([^aeiouy])y/i, '\1ies')
inflect.singular(/s$/i, '')
inflect.singular(/(ss)$/i, '\1')
inflect.singular(/([^aeiouy]o)es/, '\1')
inflect.singular(/([^aeiouy])ies/i, '\1y')
inflect.irregular('child', 'children')
inflect.irregular('person', 'people')
inflect.irregular('self', 'selves')
inflect.uncountable(%w(series))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment