From 07d8294b943a7978f09720fac353498f462d716a Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Fri, 14 Jun 2013 17:51:36 +0200 Subject: Changing const_regexp to check for constant name. We need to return Regexp.escape(camel_cased_word) if the split is blank. --- activesupport/lib/active_support/inflector/methods.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 665545db3b..9f417af826 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -322,6 +322,9 @@ module ActiveSupport # For instance, Foo::Bar::Baz will generate Foo(::Bar(::Baz)?)? def const_regexp(camel_cased_word) #:nodoc: parts = camel_cased_word.split("::") + + return Regexp.escape(camel_cased_word) if parts.blank? + last = parts.pop parts.reverse.inject(last) do |acc, part| -- cgit v1.2.3