According to the rail source , it looks like remote_ip obtained from 3 separate headers, HTTP_CLIENT_IP , HTTP_X_FORWARDED_FOR and REMOTE_ADDR . Thus, if you are worried that you may receive a request that does not have any of these headers, then it looks like remote_ip might be nil (it looks something like the ip rack implementation). From what I read, it is safe enough to assume that the REMOTE_ADDR header will be present in most HTTP requests, so it is unlikely that any of these values โโwill be zero.
source share