Skip to content

Commit

Permalink
Deprecate passing an invalid name to Formatter#generate
Browse files Browse the repository at this point in the history
The internal tests that (incorrectly) relied on this were already fixed in
938d130. However, we cannot simply fix this bug because the guides prior to
b7b9e92 recommended a workaround that relies on this buggy behavior.

Reference #17453
  • Loading branch information
chancancode committed Nov 23, 2014
1 parent 938d130 commit c23bb15
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions actionpack/lib/action_dispatch/journey/formatter.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'action_controller/metal/exceptions'
require 'active_support/deprecation'

module ActionDispatch
module Journey
Expand Down Expand Up @@ -80,6 +81,15 @@ def match_route(name, options)
if named_routes.key?(name)
yield named_routes[name]
else
if name
ActiveSupport::Deprecation.warn <<-MSG.squish
You are trying to generate the URL for a named route called
#{name.inspect} but no such route was found. In the future,
this will result in an `ActionController::UrlGenerationError`
exception.
MSG
end

routes = non_recursive(cache, options)

hash = routes.group_by { |_, r| r.score(options) }
Expand Down

0 comments on commit c23bb15

Please sign in to comment.