aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-06-03 14:05:16 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-06-03 14:05:42 -0700
commitcc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9 (patch)
tree5e0c138f7882a199da621ee81c19567f9d405e24 /actionpack/lib/action_dispatch/routing
parent9b09e60fbf5b17b2b6d1f8902f10bf82b5e2aa27 (diff)
downloadrails-cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9.tar.gz
rails-cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9.tar.bz2
rails-cc26b6b7bccf0eea2e2c1a9ebdcc9d30ca7390d9.zip
Routes specifying 'to:' must be a string that contains a "#" or a rack
application. Use of a symbol should be replaced with `action: symbol`. Use of a string without a "#" should be replaced with `controller: string`.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 0b13738dcb..a32e4ee0d1 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -7,6 +7,7 @@ require 'active_support/core_ext/module/remove_method'
require 'active_support/inflector'
require 'action_dispatch/routing/redirection'
require 'action_dispatch/routing/endpoint'
+require 'active_support/deprecation'
module ActionDispatch
module Routing
@@ -284,9 +285,13 @@ module ActionDispatch
def get_controller_and_action(controller, action, to, modyoule)
case to
- when Symbol then action = to.to_s
+ when Symbol
+ ActiveSupport::Deprecation.warn "defining a route where `to` is a symbol is deprecated. Please change \"to: :#{to}\" to \"action: :#{to}\""
+ action = to.to_s
when /#/ then controller, action = to.split('#')
- when String then controller = to
+ when String
+ ActiveSupport::Deprecation.warn "defining a route where `to` is a controller without an action is deprecated. Please change \"to: :#{to}\" to \"controller: :#{to}\""
+ controller = to
end
if modyoule && !controller.is_a?(Regexp)
@@ -1458,7 +1463,20 @@ module ActionDispatch
if rest.empty? && Hash === path
options = path
path, to = options.find { |name, _value| name.is_a?(String) }
- options[:to] = to
+
+ case to
+ when Symbol
+ options[:action] = to
+ when String
+ if to =~ /#/
+ options[:to] = to
+ else
+ options[:controller] = to
+ end
+ else
+ options[:to] = to
+ end
+
options.delete(path)
paths = [path]
else