diff options
author | Andre Arko <andre@arko.net> | 2011-11-14 11:22:44 -1000 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-11-14 11:23:33 -1000 |
commit | 4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e (patch) | |
tree | fb363c48e9bee983649a40d08b7b1be53066ebb9 | |
parent | cda1a5d5fe002ca92aca01586e8a60439605f960 (diff) | |
download | rails-4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e.tar.gz rails-4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e.tar.bz2 rails-4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e.zip |
Return the calculated remote_ip or ip
This was an especially nasty bug introduced in 317f4e2, by the way that an instance of GetIp is not nil, but GetIp#to_s could sometimes return nil. Gross, huh?
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 3 |
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 |