diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-01 11:45:52 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-01 11:45:59 -0700 |
commit | 8cbcd19d7079db1b5df6ddb3b813fea57cd5cc38 (patch) | |
tree | 04003c42b327f96af1dfc028089bab2f86c9c82c /actionpack/lib/action_dispatch/routing | |
parent | cfbb5a28cc2f7062f2812b97d669c6e387f0c17f (diff) | |
download | rails-8cbcd19d7079db1b5df6ddb3b813fea57cd5cc38.tar.gz rails-8cbcd19d7079db1b5df6ddb3b813fea57cd5cc38.tar.bz2 rails-8cbcd19d7079db1b5df6ddb3b813fea57cd5cc38.zip |
always return a string from find_script_name
this allows us to avoid nil checks on the return value
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 12 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 4 |
2 files changed, 9 insertions, 7 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 37be34abf8..cd94f35e8f 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -620,11 +620,13 @@ module ActionDispatch app.routes.extend Module.new { def optimize_routes_generation?; false; end 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) + if options.key? :script_name + super(options) + else + 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 } diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 518d4ca09c..ce1fe2e451 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -694,7 +694,7 @@ module ActionDispatch end def find_script_name(options) - options.delete :script_name + options.delete(:script_name) { '' } end # The +options+ argument must be a hash whose keys are *symbols*. @@ -713,7 +713,7 @@ module ActionDispatch original_script_name = options.delete(:original_script_name) script_name = find_script_name options - if script_name && original_script_name + if original_script_name script_name = original_script_name + script_name end |