diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-05 10:05:54 +0000 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2014-01-05 10:27:46 +0000 |
commit | 892c539591c001285792b7865fe5d70846b0041b (patch) | |
tree | 0bf8916e63ecb5eaefd48cb3ac098f7a975f0147 /actionpack/lib/action_dispatch | |
parent | b9efc74f9e63e76f121204a96073d2f5582f66e6 (diff) | |
download | rails-892c539591c001285792b7865fe5d70846b0041b.tar.gz rails-892c539591c001285792b7865fe5d70846b0041b.tar.bz2 rails-892c539591c001285792b7865fe5d70846b0041b.zip |
Show full route constraints in error message
When an optimized helper fails to generate, show the full route constraints
in the error message. Previously it would only show the contraints that were
required as part of the path.
Fixes #13592
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/formatter.rb | 4 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 5 |
2 files changed, 5 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index 7764763791..4410c1b5d5 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -33,8 +33,8 @@ module ActionDispatch return [route.format(parameterized_parts), params] end - message = "No route matches #{constraints.inspect}" - message << " missing required keys: #{missing_keys.inspect}" if name + message = "No route matches #{Hash[constraints.sort].inspect}" + message << " missing required keys: #{missing_keys.sort.inspect}" if name raise ActionController::UrlGenerationError, message end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 1ea3bb17ce..10c8d748df 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -210,8 +210,9 @@ module ActionDispatch end def raise_generation_error(args, missing_keys) - message = "No route matches #{args.inspect}" - message << " missing required keys: #{missing_keys.inspect}" + constraints = Hash[@route.requirements.merge(args).sort] + message = "No route matches #{constraints.inspect}" + message << " missing required keys: #{missing_keys.sort.inspect}" raise ActionController::UrlGenerationError, message end |