mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04: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:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user