aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/routing.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-09-17 09:30:18 +0000
committerMichael Koziarski <michael@koziarski.com>2007-09-17 09:30:18 +0000
commit7cb26b5d2d0ecb4945f01b1aa1d398eb85c9f1a4 (patch)
tree24f361b1f6e4e6738ebb71344dcb61f0ac2f50fa /actionpack/lib/action_controller/routing.rb
parentacbec3e565909da5811488e88066a01f71b68a94 (diff)
downloadrails-7cb26b5d2d0ecb4945f01b1aa1d398eb85c9f1a4.tar.gz
rails-7cb26b5d2d0ecb4945f01b1aa1d398eb85c9f1a4.tar.bz2
rails-7cb26b5d2d0ecb4945f01b1aa1d398eb85c9f1a4.zip
Disable optimisation code for UrlWriter as request.host doesn't make sense there.
Don't try to use the .to_query method when the route has no dynamic segments. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7501 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/routing.rb')
-rw-r--r--actionpack/lib/action_controller/routing.rb20
1 files changed, 14 insertions, 6 deletions
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index adeb70235c..faaecb8964 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -342,7 +342,7 @@ module ActionController
# Indicates whether the routes should be optimised with the string interpolation
# version of the named routes methods.
def optimise?
- @optimise
+ @optimise && ActionController::Routing::optimise_named_routes
end
def segment_keys
@@ -1004,8 +1004,7 @@ module ActionController
# 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) && ActionController::Routing.optimise_named_routes
-
+ route.optimise = !options.key?(:requirements)
if !route.significant_keys.include?(:action) && !route.requirements[:action]
route.requirements[:action] = "index"
route.significant_keys << :action
@@ -1119,7 +1118,16 @@ module ActionController
routes.length
end
- def install(destinations = [ActionController::Base, ActionView::Base])
+ def reset!
+ old_routes = routes.dup
+ clear!
+ old_routes.each do |name, route|
+ add(name, route)
+ end
+ end
+
+ def install(destinations = [ActionController::Base, ActionView::Base], regenerate = false)
+ reset! if regenerate
Array(destinations).each { |dest| dest.send :include, @module }
end
@@ -1219,9 +1227,9 @@ module ActionController
@routes_by_controller = nil
end
- def install_helpers(destinations = [ActionController::Base, ActionView::Base])
+ def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)
Array(destinations).each { |d| d.send :include, Helpers }
- named_routes.install(destinations)
+ named_routes.install(destinations, regenerate_code)
end
def empty?