From 33d6e3be623d4dbcec077e62699272cbdcd23f37 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 13 May 2014 15:35:41 -0700 Subject: [PATCH] drop || test for cases that do not need it --- actionpack/lib/action_dispatch/routing/mapper.rb | 4 +++- actionpack/lib/action_dispatch/routing/route_set.rb | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d75ea9394c..58c7f5330e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -580,11 +580,13 @@ module ActionDispatch app.routes.define_mounted_helper(name) app.routes.extend Module.new { def mounted?; true; end - define_method :_generate_prefix do |options| + define_method :find_script_name do |options| + super(options) || begin prefix_options = options.slice(*_route.segment_keys) # we must actually delete prefix segment keys to avoid passing them to next url_for _route.segment_keys.each { |k| options.delete(k) } _routes.url_helpers.send("#{name}_path", prefix_options) + end end } end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 6fc799c0d2..8aad5907ba 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -641,8 +641,8 @@ module ActionDispatch !mounted? && default_url_options.empty? end - def _generate_prefix(options) - nil + def find_script_name(options) + options.delete :script_name end # The +options+ argument must be a hash whose keys are *symbols*. @@ -659,7 +659,7 @@ module ActionDispatch recall = options.delete(:_recall) original_script_name = options.delete(:original_script_name) - script_name = options.delete(:script_name) || _generate_prefix(options) + script_name = find_script_name options if script_name && original_script_name script_name = original_script_name + script_name