diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-29 12:03:06 -0700 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2012-08-29 12:03:06 -0700 |
commit | 46d85438fed2a44cb6e9882c532d33ca25211c57 (patch) | |
tree | 619bc2ef204998ff7b4b974d3bb2bf4296396db6 /actionpack/lib/action_dispatch/routing | |
parent | 3b2c42cb56f8f838b6a376132bd10a04bddc4045 (diff) | |
parent | cc57b2a422a18f22f8ecf6912ebfab0da0ac3c8a (diff) | |
download | rails-46d85438fed2a44cb6e9882c532d33ca25211c57.tar.gz rails-46d85438fed2a44cb6e9882c532d33ca25211c57.tar.bz2 rails-46d85438fed2a44cb6e9882c532d33ca25211c57.zip |
Merge pull request #7230 from schneems/schneems/expose_required_keys
Add Missing Keys from Journey on Failed URL Format
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 32d267d1d6..1fe40d8458 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -438,12 +438,11 @@ module ActionDispatch attr_reader :options, :recall, :set, :named_route - def initialize(options, recall, set, extras = false) + def initialize(options, recall, set) @named_route = options.delete(:use_route) @options = options.dup @recall = recall.dup @set = set - @extras = extras normalize_options! normalize_controller_action_id! @@ -526,20 +525,12 @@ module ActionDispatch recall[:action] = options.delete(:action) if options[:action] == 'index' end + # Generates a path from routes, returns [path, params] + # if no path is returned the formatter will raise Journey::Router::RoutingError def generate - path, params = @set.formatter.generate(:path_info, named_route, options, recall, PARAMETERIZE) - - raise_routing_error unless path - - return [path, params.keys] if @extras - - [path, params] - rescue Journey::Router::RoutingError - raise_routing_error - end - - def raise_routing_error - raise ActionController::RoutingError, "No route matches #{options.inspect}" + @set.formatter.generate(:path_info, named_route, options, recall, PARAMETERIZE) + rescue Journey::Router::RoutingError => e + raise ActionController::UrlGenerationError, "No route matches #{options.inspect} #{e.message}" end def different_controller? @@ -564,11 +555,12 @@ module ActionDispatch end def generate_extras(options, recall={}) - generate(options, recall, true) + path, params = generate(options, recall) + return path, params.keys end - def generate(options, recall = {}, extras = false) - Generator.new(options, recall, self, extras).generate + def generate(options, recall = {}) + Generator.new(options, recall, self).generate end RESERVED_OPTIONS = [:host, :protocol, :port, :subdomain, :domain, :tld_length, |