1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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?
This commit is contained in:
Andre Arko 2011-11-14 11:22:44 -10:00
parent cda1a5d5fe
commit 4f2bf6491c

View file

@ -157,7 +157,8 @@ module ActionDispatch
# Originating IP address, usually set by the RemoteIp middleware. # Originating IP address, usually set by the RemoteIp middleware.
def remote_ip 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 end
# Returns the unique request id, which is based off either the X-Request-Id header that can # Returns the unique request id, which is based off either the X-Request-Id header that can