This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Understanding Pluralization Rules
CodeExpectedActual
class Order < ActiveRecord::Base
  has_many :line_items
end
Rails::Initializer.run do |config|
  config.active_record.pluralize_table_names = false
end
Inflector.inflections do |inflect|
  inflect.plural /^(foo)$/i, '\1ze'
  inflect.singular /^(foo)ze/i, '\1'
end
Inflector.inflections do |inflect|
  inflect.irregular 'foo', 'fooze'
end
Inflector.inflections do |inflect|
  inflect.uncountable ['status', 'furniture', 'fish', 'sheep']
end
require 'rubygems'
require 'active_support/core_ext'
'blob'.pluralize
"blobs" "blobs"
'child'.pluralize
"children" "children"
'octopus'.pluralize
"octopi" "octopi"
'octopi'.singularize
"octopus" "octopus"
'people'.singularize
"person" "person"
'goose'.pluralize
"gooses" "gooses"
Inflector.inflections { |i| i.irregular 'goose', 'geese' }
'goose'.pluralize
"geese" "geese"
'moose'.pluralize
"mooses" "mooses"
Inflector.inflections { |i| i.uncountable 'moose' }
'moose'.pluralize
"moose" "moose"