diff options
author | Nicholas Seckar <nseckar@gmail.com> | 2006-02-22 17:29:22 +0000 |
---|---|---|
committer | Nicholas Seckar <nseckar@gmail.com> | 2006-02-22 17:29:22 +0000 |
commit | de54db3c1e2056322450e46c265b27792e99b2c7 (patch) | |
tree | 7894c7672b3d4c8b11061eb57a671bb9f76f7d94 /actionpack/lib | |
parent | bb7408fd4ca0cfe41b4145fec088b36c185c969e (diff) | |
download | rails-de54db3c1e2056322450e46c265b27792e99b2c7.tar.gz rails-de54db3c1e2056322450e46c265b27792e99b2c7.tar.bz2 rails-de54db3c1e2056322450e46c265b27792e99b2c7.zip |
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
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/routing.rb | 10 |
1 files changed, 7 insertions, 3 deletions
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 |