aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-03-03 19:18:01 +0000
committerAndrew White <andyw@pixeltrix.co.uk>2013-03-03 19:18:01 +0000
commit86cf7a2d166430fac1611aa7593b52b46eeb9f70 (patch)
tree998de220aab255a787bfbcf21341e71f5b6e6edb /actionpack/lib/action_dispatch/routing/route_set.rb
parent48c21e3255fa2f4b1875ca8616a5ad7706a7a4cb (diff)
downloadrails-86cf7a2d166430fac1611aa7593b52b46eeb9f70.tar.gz
rails-86cf7a2d166430fac1611aa7593b52b46eeb9f70.tar.bz2
rails-86cf7a2d166430fac1611aa7593b52b46eeb9f70.zip
Use custom visitor class for optimized url helpers
Rather than trying to use gsub to remove the optional route segments, which will fail with nested optional segments, use a custom visitor class that returns a empty string for group nodes. Closes #9524
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb10
1 files changed, 1 insertions, 9 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index ca31b5e02e..619dd22ec1 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -165,7 +165,7 @@ module ActionDispatch
super
@path_parts = @route.required_parts
@arg_size = @path_parts.size
- @string_route = string_route(route)
+ @string_route = @route.optimized_path
end
def call(t, args)
@@ -180,14 +180,6 @@ module ActionDispatch
private
- def string_route(route)
- string_route = route.ast.to_s.dup
- while string_route.gsub!(/\([^\)]*\)/, "")
- true
- end
- string_route
- end
-
def optimized_helper(args)
path = @string_route.dup
klass = Journey::Router::Utils