aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-08-09 00:02:08 +0000
committerRick Olson <technoweenie@gmail.com>2006-08-09 00:02:08 +0000
commit4679e1bf7f83b501f4a9507d530d4c707d16921f (patch)
tree36c51d11991f4d56af75709be7b49a36a039e531 /actionpack/lib
parente9b02840708226e5cf49a75364f7e273ef8f020e (diff)
downloadrails-4679e1bf7f83b501f4a9507d530d4c707d16921f.tar.gz
rails-4679e1bf7f83b501f4a9507d530d4c707d16921f.tar.bz2
rails-4679e1bf7f83b501f4a9507d530d4c707d16921f.zip
Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4733 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_controller/routing.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index 5d5f1809b7..8dd5f37a8b 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -981,9 +981,10 @@ module ActionController
end
def generate(options, recall = {}, method=:generate)
- if options[:use_route]
+ named_route_name = options.delete(:use_route)
+ if named_route_name
options = options.dup
- named_route = named_routes[options.delete(:use_route)]
+ named_route = named_routes[named_route_name]
options = named_route.parameter_shell.merge(options)
end
@@ -1006,7 +1007,9 @@ module ActionController
merged = recall.merge(options)
if named_route
- return named_route.generate(options, merged, expire_on)
+ path = named_route.generate(options, merged, expire_on)
+ raise RoutingError, "#{named_route_name}_url failed to generate from #{options.inspect}, missing: #{(named_route.significant_keys - options.keys).inspect}" if path.nil?
+ return path
else
merged[:action] ||= 'index'
options[:action] ||= 'index'
@@ -1014,7 +1017,7 @@ module ActionController
controller = merged[:controller]
action = merged[:action]
- raise "Need controller and action!" unless controller && action
+ raise RoutingError, "Need controller and action!" unless controller && action
# don't use the recalled keys when determining which routes to check
routes = routes_by_controller[controller][action][options.keys.sort_by { |x| x.object_id }]