Browse files

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?
  • Loading branch information...
1 parent cda1a5d commit 4f2bf6491cbc482d25a9357c2eb7fc8047d4f12e @indirect indirect committed Nov 14, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 actionpack/lib/action_dispatch/http/request.rb
@@ -157,7 +157,8 @@ def ip
# 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

sobrinho Nov 15, 2011


Do not make sense fixing GetIp#to_s instead of here?


indirect Nov 15, 2011


I did: indirect/rails@d743954. Waiting for someone on core to tell me if it's a good idea or not. :P

# Returns the unique request id, which is based off either the X-Request-Id header that can

0 comments on commit 4f2bf64

Please sign in to comment.