diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2012-05-03 18:44:12 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2012-05-03 18:44:12 +0300 |
commit | 1ab0523cfd405f2f8097841405947c0d26b72150 (patch) | |
tree | 266c2bb7dd87b10c67aa6be2f3d3744c5641545d /actionpack/lib/action_dispatch | |
parent | 9de9e6a278d1a8dd3f2ceb2d9f8d5bbd3680bd76 (diff) | |
download | rails-1ab0523cfd405f2f8097841405947c0d26b72150.tar.gz rails-1ab0523cfd405f2f8097841405947c0d26b72150.tar.bz2 rails-1ab0523cfd405f2f8097841405947c0d26b72150.zip |
RouteSet: optimize routes generation when globbing is used
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 57ce7b4ba9..7abd7bd008 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -202,7 +202,7 @@ module ActionDispatch # Clause check about when we need to generate an optimized helper. def optimize_helper?(route) #:nodoc: - route.ast.grep(Journey::Nodes::Star).empty? && route.requirements.except(:controller, :action).empty? + route.requirements.except(:controller, :action).empty? end # Generates the interpolation to be used in the optimized helper. @@ -214,7 +214,10 @@ module ActionDispatch end route.required_parts.each_with_index do |part, i| - string_route.gsub!(part.inspect, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}") + # Replace each route parameter + # e.g. :id for regular parameter or *path for globbing + # with ruby string interpolation code + string_route.gsub!(/(\*|:)#{part}/, "\#{Journey::Router::Utils.escape_fragment(args[#{i}].to_param)}") end string_route |