From f91096a543895a49876ec8e276cefefff6fdbe5a Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Mon, 22 May 2006 15:17:45 +0000 Subject: Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4359 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/CHANGELOG | 2 ++ activesupport/lib/active_support/inflector.rb | 2 +- activesupport/test/inflector_test.rb | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG index f796774f0f..7b98b2dbed 100644 --- a/activesupport/CHANGELOG +++ b/activesupport/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.] + * Strip out leading schema name in classify. References #5139. [schoenm@earthlink.net] * Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar] diff --git a/activesupport/lib/active_support/inflector.rb b/activesupport/lib/active_support/inflector.rb index 54b9e064ac..a578ecb95e 100644 --- a/activesupport/lib/active_support/inflector.rb +++ b/activesupport/lib/active_support/inflector.rb @@ -147,7 +147,7 @@ module Inflector def classify(table_name) # strip out any leading schema name - camelize(singularize(table_name.sub(/.*\./, ''))) + camelize(singularize(table_name.to_s.sub(/.*\./, ''))) end def foreign_key(class_name, separate_class_name_and_id_with_underscore = true) diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index c0a2b76a5a..e1676281ad 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -278,6 +278,12 @@ class InflectorTest < Test::Unit::TestCase assert_equal(class_name, Inflector.classify(table_name)) end end + + def test_classify_with_symbol + assert_nothing_raised do + assert_equal 'FooBar', Inflector.classify(:foo_bar) + end + end def test_humanize UnderscoreToHuman.each do |underscore, human| -- cgit v1.2.3