aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/http/request.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-11-14 13:27:36 -0800
committerJosé Valim <jose.valim@gmail.com>2011-11-14 13:27:36 -0800
commit25c9e44a21511255fd4da4b584e4c8b4415476d8 (patch)
treefb363c48e9bee983649a40d08b7b1be53066ebb9 /actionpack/lib/action_dispatch/http/request.rb
parent9fa329b7544b15cdf5751d518e380abc82468df0 (diff)
parent4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e (diff)
downloadrails-25c9e44a21511255fd4da4b584e4c8b4415476d8.tar.gz
rails-25c9e44a21511255fd4da4b584e4c8b4415476d8.tar.bz2
rails-25c9e44a21511255fd4da4b584e4c8b4415476d8.zip
Merge pull request #3631 from indirect/remote_ip
Force calculation of remote IP before using || operator
Diffstat (limited to 'actionpack/lib/action_dispatch/http/request.rb')
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 69ca050d0c..b10f6b48c7 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -157,7 +157,8 @@ module ActionDispatch
# Originating IP address, usually set by the RemoteIp middleware.
def remote_ip
- @remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s
+ # Coerce the remote_ip object into a string, because to_s could return nil
+ @remote_ip ||= @env["action_dispatch.remote_ip"].to_s || ip
end
# Returns the unique request id, which is based off either the X-Request-Id header that can