From 6c367a0d787705746f262d0bd5ad8c4f13a8c809 Mon Sep 17 00:00:00 2001 From: Alex Tambellini Date: Thu, 26 Jan 2012 14:19:49 -0500 Subject: safe_constantize should handle wrong constant name NameErrors Fixes #4710 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/inflector/methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 1dc2e0487f..f47dfba4b0 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -258,7 +258,7 @@ module ActiveSupport begin constantize(camel_cased_word) rescue NameError => e - raise unless e.message =~ /uninitialized constant #{const_regexp(camel_cased_word)}$/ || + raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ || e.name.to_s == camel_cased_word.to_s rescue ArgumentError => e raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\!$/ -- cgit v1.2.3