Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve documentation to classify to make it clear that it expects na…

…mes to be plural. Reference #10615 [kris_chambers]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8596 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 96d3b7ced4cb322fdbb9d1899221cce93a30f14f 1 parent 8f7fa55
Michael Koziarski NZKoz authored
7 activesupport/lib/active_support/core_ext/string/inflections.rb
View
@@ -104,13 +104,16 @@ def tableize
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
7 activesupport/lib/active_support/inflector.rb
View
@@ -218,13 +218,16 @@ def tableize(class_name)
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(/.*\./, '')))
Please sign in to comment.
Something went wrong with that request. Please try again.