Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 4953563e088bd23ef36ef4a76543deef5369fa9a 1 parent 26174b2
Michael Koziarski NZKoz authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 actionpack/lib/action_controller/routing_optimisation.rb
8 actionpack/lib/action_controller/routing_optimisation.rb
View
@@ -60,9 +60,9 @@ def guard_condition
# 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 @@ def generation_code
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 @@ def generation_code
# 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,
Please sign in to comment.
Something went wrong with that request. Please try again.