From 7bc25f003502633eadc26b5cbafebb66f578c058 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 21 May 2014 11:55:15 -0700 Subject: do not mutate parameters, let the caller do mutations --- actionpack/lib/action_dispatch/journey/formatter.rb | 6 ++++++ actionpack/lib/action_dispatch/journey/route.rb | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_dispatch/journey/formatter.rb b/actionpack/lib/action_dispatch/journey/formatter.rb index aa8d5a4d79..7eaf8e49ce 100644 --- a/actionpack/lib/action_dispatch/journey/formatter.rb +++ b/actionpack/lib/action_dispatch/journey/formatter.rb @@ -30,6 +30,12 @@ module ActionDispatch parameterized_parts.key?(key) || route.defaults.key?(key) end + defaults = route.defaults + required_parts = route.required_parts + parameterized_parts.delete_if do |key, value| + value.to_s == defaults[key].to_s && !required_parts.include?(key) + end + return [route.format(parameterized_parts), params] end diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index 982ff3e259..1effcd5a5e 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -73,10 +73,6 @@ module ActionDispatch alias :segment_keys :parts def format(path_options) - path_options.delete_if do |key, value| - value.to_s == defaults[key].to_s && !required_parts.include?(key) - end - @formatter.evaluate path_options end -- cgit v1.2.3