diff options
author | Michael Koziarski <michael@koziarski.com> | 2007-09-29 02:19:16 +0000 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2007-09-29 02:19:16 +0000 |
commit | 4953563e088bd23ef36ef4a76543deef5369fa9a (patch) | |
tree | 1d33387a47a9f7bb948d2dd6edf2d5f4d91f1723 /actionpack | |
parent | 26174b2881c8f71a1477a1d69353262e682cbd32 (diff) | |
download | rails-4953563e088bd23ef36ef4a76543deef5369fa9a.tar.gz rails-4953563e088bd23ef36ef4a76543deef5369fa9a.tar.bz2 rails-4953563e088bd23ef36ef4a76543deef5369fa9a.zip |
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
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/routing_optimisation.rb | 8 |
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, |