From de54db3c1e2056322450e46c265b27792e99b2c7 Mon Sep 17 00:00:00 2001 From: Nicholas Seckar Date: Wed, 22 Feb 2006 17:29:22 +0000 Subject: Check NameErrors and re-raise if they do not match the expected constant git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3636 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/routing.rb') diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb index af9baa54af..3354e8444f 100644 --- a/actionpack/lib/action_controller/routing.rb +++ b/actionpack/lib/action_controller/routing.rb @@ -232,7 +232,7 @@ module ActionController mod_name = segment.camelize controller_name = "#{mod_name}Controller" - suppress(NameError) do + begin controller = eval("mod::#{controller_name}", nil, __FILE__, __LINE__) expected_name = "#{mod.name}::#{controller_name}" @@ -240,12 +240,16 @@ module ActionController if controller.is_a?(Class) && controller.ancestors.include?(ActionController::Base) && (mod == Object || controller.name == expected_name) return controller, (index - start_at) end + rescue NameError => e + raise unless /^uninitialized constant #{controller_name}$/ =~ e.message end - mod = suppress(NameError) do + begin next_mod = eval("mod::#{mod_name}", nil, __FILE__, __LINE__) # Check that we didn't get a module from a parent namespace - (mod == Object || next_mod.name == "#{mod.name}::#{mod_name}") ? next_mod : nil + mod = (mod == Object || next_mod.name == "#{mod.name}::#{mod_name}") ? next_mod : nil + rescue NameError => e + raise unless /^uninitialized constant #{mod_name}$/ =~ e.message end return nil unless mod -- cgit v1.2.3