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:
parent
cda1a5d5fe
commit
4f2bf6491c
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue