hoodwink.d enhanced

Thu Oct 13

Tip Customize the inflector in edge Rails

If you’re riding the development version of Rails, you can customize the inflector to create or override pluralization rules in environment.rb.

Inflector.inflections do |inflect|
  inflect.plural /^(ox)$/i, '1en'
  inflect.singular /^(ox)en/i, '1'
  inflect.irregular 'person', 'people'
  inflect.uncountable %w( fish sheep )
end

Note that the inflection rules are frozen now in Rails trunk, so this is the way to bend them to your needs.

Money tends to make you more agile.

David Black