aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/routing.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-11-20 21:25:25 +0000
committerMichael Koziarski <michael@koziarski.com>2007-11-20 21:25:25 +0000
commit0c12d6c6dc66cb7873969fc7f982ad9244a4ea00 (patch)
tree6b375f5db19b2323b3f67b0204c2658f5f271851 /actionpack/lib/action_controller/routing.rb
parente1a2f3c898be4048f00eb6e8909f63da0116789a (diff)
downloadrails-0c12d6c6dc66cb7873969fc7f982ad9244a4ea00.tar.gz
rails-0c12d6c6dc66cb7873969fc7f982ad9244a4ea00.tar.bz2
rails-0c12d6c6dc66cb7873969fc7f982ad9244a4ea00.zip
Ensure that the routing optimisation code isn't used when additional arguments are passed to the named route. Closes #10209 [bscofield, Koz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/routing.rb')
-rw-r--r--actionpack/lib/action_controller/routing.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index bebad04eab..2e8951e36d 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -273,6 +273,8 @@ module ActionController
HTTP_METHODS = [:get, :head, :post, :put, :delete]
+ ALLOWED_REQUIREMENTS_FOR_OPTIMISATION = [:controller, :action].to_set
+
# The root paths which may contain controller files
mattr_accessor :controller_paths
self.controller_paths = []
@@ -353,6 +355,7 @@ module ActionController
@segments = []
@requirements = {}
@conditions = {}
+ @optimise = true
end
# Indicates whether the routes should be optimised with the string interpolation
@@ -1021,15 +1024,18 @@ module ActionController
route.requirements = requirements
route.conditions = conditions
- # Routes cannot use the current string interpolation method
- # if there are user-supplied :requirements as the interpolation
- # code won't raise RoutingErrors when generating
- route.optimise = !options.key?(:requirements)
if !route.significant_keys.include?(:action) && !route.requirements[:action]
route.requirements[:action] = "index"
route.significant_keys << :action
end
+ # Routes cannot use the current string interpolation method
+ # if there are user-supplied :requirements as the interpolation
+ # code won't raise RoutingErrors when generating
+ if options.key?(:requirements) || route.requirements.keys.to_set != Routing::ALLOWED_REQUIREMENTS_FOR_OPTIMISATION
+ route.optimise = false
+ end
+
if !route.significant_keys.include?(:controller)
raise ArgumentError, "Illegal route: the :controller must be specified!"
end