Browse files

Add parameter to #classify singular table names

Allow `ActiveSupport::Inflector.classify` to treat singular table names by adding a parameter `singular` with default value `false`.
  • Loading branch information...
1 parent a5fa310 commit 899d6cd0a759e0126f35e6cdf41839d9b6f8d0a2 @alexeymuranov committed Dec 24, 2011
Showing with 4 additions and 2 deletions.
  1. +4 −2 activesupport/lib/active_support/inflector/methods.rb
View
6 activesupport/lib/active_support/inflector/methods.rb
@@ -133,9 +133,11 @@ def tableize(class_name)
#
# Singular names are not handled correctly:
# "business".classify # => "Busines"
- def classify(table_name)
+ def classify(table_name, singular = false)
# strip out any leading schema name
- camelize(singularize(table_name.to_s.sub(/.*\./, '')))
+ underscored_name = table_name.to_s.sub(/.*\./, '')
+ underscored_name = singularize(underscored_name) unless singular
+ camelize(underscored_name)
end
# Replaces underscores with dashes in the string.

0 comments on commit 899d6cd

Please sign in to comment.