diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-07-03 08:14:17 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-07-03 10:06:07 +0200 |
commit | 54250a5bfe6992afaaca6357d3b414e6c49651ba (patch) | |
tree | 70636f67d57a7c6e0667505ea7aecf94eb159179 /actionpack/lib/action_dispatch | |
parent | 8cc746331c32a6951e5c73c8a21fd32f00680471 (diff) | |
download | rails-54250a5bfe6992afaaca6357d3b414e6c49651ba.tar.gz rails-54250a5bfe6992afaaca6357d3b414e6c49651ba.tar.bz2 rails-54250a5bfe6992afaaca6357d3b414e6c49651ba.zip |
Refactor recall parameter normalization [#5021 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index afa312889f..177a6db04e 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -318,7 +318,6 @@ module ActionDispatch @extras = extras normalize_options! - normalize_recall! normalize_controller_action_id! use_relative_controller! controller.sub!(%r{^/}, '') if controller @@ -335,7 +334,11 @@ module ActionDispatch def use_recall_for(key) if @recall[key] && (!@options.key?(key) || @options[key] == @recall[key]) - @options[key] = @recall.delete(key) + if named_route_exists? + @options[key] = @recall.delete(key) if segment_keys.include?(key) + else + @options[key] = @recall.delete(key) + end end end @@ -359,15 +362,6 @@ module ActionDispatch end end - def normalize_recall! - # If the target route is not a standard route then remove controller and action - # from the options otherwise they will appear in the url parameters - if block_or_proc_route_target? - recall.delete(:controller) unless segment_keys.include?(:controller) - recall.delete(:action) unless segment_keys.include?(:action) - end - end - # This pulls :controller, :action, and :id out of the recall. # The recall key is only used if there is no key in the options # or if the key in the options is identical. If any of @@ -440,12 +434,8 @@ module ActionDispatch named_route && set.named_routes[named_route] end - def block_or_proc_route_target? - named_route_exists? && !set.named_routes[named_route].app.is_a?(Dispatcher) - end - def segment_keys - named_route_exists? ? set.named_routes[named_route].segment_keys : [] + set.named_routes[named_route].segment_keys end end |