diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-25 10:37:42 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-01-30 10:24:58 -0800 |
commit | 8e5b4372d088e933b5f64c400e299fc9c7a6967c (patch) | |
tree | 832ffbe7b994c8f51ba8e65d968f0014765acb07 /actionpack/lib/action_dispatch/routing | |
parent | 27bccf02ee41f6bca207f96ef3ca31ca0c206964 (diff) | |
download | rails-8e5b4372d088e933b5f64c400e299fc9c7a6967c.tar.gz rails-8e5b4372d088e933b5f64c400e299fc9c7a6967c.tar.bz2 rails-8e5b4372d088e933b5f64c400e299fc9c7a6967c.zip |
stop evaling a string every time
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index d7426238a1..eae3e35ba1 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -169,7 +169,7 @@ module ActionDispatch def call(t, args) if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t) @options.merge!(t.url_options) if t.respond_to?(:url_options) - @options[:path] = eval("\"#{optimized_helper}\"") + @options[:path] = optimized_helper(args) ActionDispatch::Http::URL.url_for(@options) else super @@ -178,8 +178,8 @@ module ActionDispatch private - def optimized_helper - string_route = @route.ast.to_s + def optimized_helper(args) + string_route = @route.ast.to_s.dup while string_route.gsub!(/\([^\)]*\)/, "") true @@ -189,7 +189,7 @@ module ActionDispatch # 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)}") + string_route.gsub!(/(\*|:)#{part}/, Journey::Router::Utils.escape_fragment(args[i].to_param)) end string_route |