Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 899d6cd0a759e0126f35e6cdf41839d9b6f8d0a2 1 parent a5fa310
@alexeymuranov authored
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.
Please sign in to comment.
Something went wrong with that request. Please try again.