Today I Learned

A CCSalesPro project TwitterFollow on Twitter

Add custom inflectors for irregular words

ActiveSupport::Inflector allows you to add custom inflections for words it doesn't know how to pluralize already:

# config/initializers/inflections.rb
ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.irregular "evidence", "evidence"
  #   inflect.plural /^(ox)$/i, "\\1en"
  #   inflect.plural /^(ox)$/i, "\\1en"
  #   inflect.singular /^(ox)en/i, "\\1"
  #   inflect.irregular "person", "people"
  #   inflect.uncountable %w( fish sheep )
end

This allows us to use evidence as a table name with a model called Evidence

puts "evidence".pluralize
"evidence"