diff options
author | Michael Koziarski <michael@koziarski.com> | 2008-01-08 21:15:49 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-01-08 21:15:49 +0000 |
commit | 96d3b7ced4cb322fdbb9d1899221cce93a30f14f (patch) | |
tree | 77d3c38a7ff5edb41051680fce31d78c63c19c46 /activesupport/lib | |
parent | 8f7fa55e8da2463136f2e28c0a5680783ae85fbc (diff) | |
download | rails-96d3b7ced4cb322fdbb9d1899221cce93a30f14f.tar.gz rails-96d3b7ced4cb322fdbb9d1899221cce93a30f14f.tar.bz2 rails-96d3b7ced4cb322fdbb9d1899221cce93a30f14f.zip |
Improve documentation to classify to make it clear that it expects names to be plural. Reference #10615 [kris_chambers]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8596 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/core_ext/string/inflections.rb | 7 | ||||
-rw-r--r-- | activesupport/lib/active_support/inflector.rb | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index dec6c9f016..72a93c217f 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -104,13 +104,16 @@ module ActiveSupport #:nodoc: Inflector.tableize(self) end - # Create a class name from a table name like Rails does for table names to models. + # Create a class name from a plural table name like Rails does for table names to models. # Note that this returns a string and not a Class. (To convert to an actual class # follow classify with constantize.) # # Examples # "egg_and_hams".classify #=> "EggAndHam" - # "post".classify #=> "Post" + # "posts".classify #=> "Post" + # + # Singular names are not handled correctly + # "business".classify #=> "Busines" def classify Inflector.classify(self) end diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index ee5d5753c9..8fca3e36da 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -218,13 +218,16 @@ module Inflector pluralize(underscore(class_name)) end - # Create a class name from a table name like Rails does for table names to models. + # Create a class name from a plural table name like Rails does for table names to models. # Note that this returns a string and not a Class. (To convert to an actual class # follow classify with constantize.) # # Examples # "egg_and_hams".classify #=> "EggAndHam" - # "post".classify #=> "Post" + # "posts".classify #=> "Post" + # + # Singular names are not handled correctly + # "business".classify #=> "Busines" def classify(table_name) # strip out any leading schema name camelize(singularize(table_name.to_s.sub(/.*\./, ''))) |