aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authoraditya-kapoor <aditya.kapoor@vinsol.com>2013-05-16 01:54:54 +0530
committeraditya-kapoor <aditya.kapoor@vinsol.com>2013-05-16 01:54:54 +0530
commit8f901dee9e2072dd20e0a252a89dd501d783d85b (patch)
treeb81a6b77c0cdfa26dd8162d76fdb73c73f287f1e /activesupport
parent90e60aa4694be408b299085cad8b8a6be64df0ac (diff)
downloadrails-8f901dee9e2072dd20e0a252a89dd501d783d85b.tar.gz
rails-8f901dee9e2072dd20e0a252a89dd501d783d85b.tar.bz2
rails-8f901dee9e2072dd20e0a252a89dd501d783d85b.zip
Corrected documentation and added some more for the classify method in inflectors
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb19
1 files changed, 14 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 39648727fd..3c46cd9690 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -138,16 +138,25 @@ module ActiveSupport
pluralize(underscore(class_name))
end
- # 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+).
+ # 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+.)
#
# 'egg_and_hams'.classify # => "EggAndHam"
# 'posts'.classify # => "Post"
#
- # Singular names are not handled correctly:
+ # Earlier in the Rails 3.2.x series, the some of the singular names were not handled correctly such as
+ # for "business", "address" the classify function would return "busines" and "addres" respectively.. but now
+ # this has been resolved and corrected in Rails 4
+ #
+ # 'business'.classify # => "Business"
+ # 'address'.classify # => "Address"
#
- # 'business'.classify # => "Busines"
+ # Yet some singular names are not handled correctly and I guess we would work upon it to improve upon these shortcomings
+ #
+ # "radius".classify #=> "Radiu" it should be "Radius"
+ # "feet".classify #=> "Foot", it should be "Feet"
+ # "abacus".classify #=> "Abacu" it should be "Abacus"
def classify(table_name)
# strip out any leading schema name
camelize(singularize(table_name.to_s.sub(/.*\./, '')))