diff options
author | Godfrey Chan <godfreykfc@gmail.com> | 2014-11-23 01:18:33 -0800 |
---|---|---|
committer | Godfrey Chan <godfreykfc@gmail.com> | 2014-11-23 01:40:32 -0800 |
commit | c23bb156fe29481c3c900e9a4bd3c1f84e71c6d0 (patch) | |
tree | 56fc8ede8e7c5dee69a5550aa031abd01d228259 /actionpack | |
parent | 938d130c62b530d3445c9f06933cb113ff477fed (diff) | |
download | rails-c23bb156fe29481c3c900e9a4bd3c1f84e71c6d0.tar.gz rails-c23bb156fe29481c3c900e9a4bd3c1f84e71c6d0.tar.bz2 rails-c23bb156fe29481c3c900e9a4bd3c1f84e71c6d0.zip |
Deprecate passing an invalid name to `Formatter#generate`
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
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/formatter.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index 992c1a9efe..62bd4a33f2 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -1,4 +1,5 @@ require 'action_controller/metal/exceptions' +require 'active_support/deprecation' module ActionDispatch module Journey @@ -80,6 +81,15 @@ module ActionDispatch 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) } |