aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r--actionpack/lib/action_controller/routing_optimisation.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/routing_optimisation.rb b/actionpack/lib/action_controller/routing_optimisation.rb
index b1bf3916d6..9b109dce60 100644
--- a/actionpack/lib/action_controller/routing_optimisation.rb
+++ b/actionpack/lib/action_controller/routing_optimisation.rb
@@ -60,9 +60,9 @@ module ActionController
# if they're using foo_url(:id=>2) it's one
# argument, but we don't want to generate /foos/id2
if number_of_arguments == 1
- "defined?(request) && args.size == 1 && !args.first.is_a?(Hash)"
+ "defined?(request) && request && args.size == 1 && !args.first.is_a?(Hash)"
else
- "defined?(request) && args.size == #{number_of_arguments}"
+ "defined?(request) && request && args.size == #{number_of_arguments}"
end
end
@@ -75,7 +75,7 @@ module ActionController
elements << '#{request.host_with_port}'
end
- elements << '#{request.relative_url_root if request && request.relative_url_root}'
+ elements << '#{request.relative_url_root if request.relative_url_root}'
# The last entry in route.segments appears to # *always* be a
# 'divider segment' for '/' but we have assertions to ensure that
@@ -97,7 +97,7 @@ module ActionController
# argument
class PositionalArgumentsWithAdditionalParams < PositionalArguments
def guard_condition
- "defined?(request) && args.size == #{route.segment_keys.size + 1}"
+ "defined?(request) && request && args.size == #{route.segment_keys.size + 1}"
end
# This case uses almost the Use the same code as positional arguments,