Skip to content
This repository
Browse code

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 authored
7  activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -104,13 +104,16 @@ def tableize
104 104
           Inflector.tableize(self)
105 105
         end
106 106
 
107  
-        # Create a class name from a table name like Rails does for table names to models.
  107
+        # Create a class name from a plural table name like Rails does for table names to models.
108 108
         # Note that this returns a string and not a Class. (To convert to an actual class
109 109
         # follow classify with constantize.)
110 110
         #
111 111
         # Examples
112 112
         #   "egg_and_hams".classify #=> "EggAndHam"
113  
-        #   "post".classify #=> "Post"
  113
+        #   "posts".classify #=> "Post"
  114
+        #
  115
+        # Singular names are not handled correctly
  116
+        #   "business".classify #=> "Busines"
114 117
         def classify
115 118
           Inflector.classify(self)
116 119
         end
7  activesupport/lib/active_support/inflector.rb
@@ -218,13 +218,16 @@ def tableize(class_name)
218 218
     pluralize(underscore(class_name))
219 219
   end
220 220
 
221  
-  # Create a class name from a table name like Rails does for table names to models.
  221
+  # Create a class name from a plural table name like Rails does for table names to models.
222 222
   # Note that this returns a string and not a Class. (To convert to an actual class
223 223
   # follow classify with constantize.)
224 224
   #
225 225
   # Examples
226 226
   #   "egg_and_hams".classify #=> "EggAndHam"
227  
-  #   "post".classify #=> "Post"
  227
+  #   "posts".classify #=> "Post"
  228
+  #
  229
+  # Singular names are not handled correctly
  230
+  #   "business".classify #=> "Busines"
228 231
   def classify(table_name)
229 232
     # strip out any leading schema name
230 233
     camelize(singularize(table_name.to_s.sub(/.*\./, '')))

0 notes on commit 96d3b7c

Please sign in to comment.
Something went wrong with that request. Please try again.