From 4953563e088bd23ef36ef4a76543deef5369fa9a Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sat, 29 Sep 2007 02:19:16 +0000 Subject: Ensure request is present, as well as defined. [nzkoz] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7676 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/routing_optimisation.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/routing_optimisation.rb') 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, -- cgit v1.2.3