提交 4679e1bf 编写于 作者: R Rick Olson

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
上级 e9b02840
*SVN*
<<<<<<< .mine
* Add RoutingError exception when RouteSet fails to generate a path from a Named Route. [Rick Olson]
* Replace Reloadable with Reloadable::Deprecated. [Nicholas Seckar]
=======
* Deprecation: check whether instance variables have been monkeyed with before assigning them to deprecation proxies. Raises a RuntimeError if so. [Jeremy Kemper]
* Add support for the param_name parameter to the auto_complete_field helper. #5026 [david.a.williams@gmail.com]
* Deprecation! @params, @session, @flash will be removed after 1.2. Use the corresponding instance methods instead. You'll get printed warnings during tests and logged warnings in dev mode when you access either instance variable directly. [Jeremy Kemper]
>>>>>>> .r4727
* Make Routing noisy when an anchor regexp is assigned to a segment. #5674 [francois.beausoleil@gmail.com]
* Added months and years to the resolution of DateHelper#distance_of_time_in_words, such that "60 days ago" becomes "2 months ago" #5611 [pjhyett@gmail.com]
......
......@@ -981,9 +981,10 @@ def generate_extras(options, recall={})
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 @@ def generate(options, recall = {}, method=:generate)
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 @@ def generate(options, recall = {}, method=:generate)
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 }]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册