Permalink
Browse files

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
  • Loading branch information...
1 parent bb7408f commit de54db3c1e2056322450e46c265b27792e99b2c7 @seckar seckar committed Feb 22, 2006
Showing with 9 additions and 3 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +7 −3 actionpack/lib/action_controller/routing.rb
@@ -1,5 +1,7 @@
*SVN*
+* During controller resolution, update the NameError suppression to check for the expected constant. [Nicholas Seckar]
+
* Update script.aculo.us to V1.5.3 [Thomas Fuchs]
* Added various InPlaceEditor options, #3746, #3891, #3896, #3906 [Bill Burcham, ruairi, sl33p3r]
@@ -232,20 +232,24 @@ def traverse_to_controller(segments, start_at = 0)
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}"
# Detect the case when const_get returns an object from a parent namespace.
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

0 comments on commit de54db3

Please sign in to comment.