As the title goes, you can get the client's ip with both methods. I wonder if there is any differences. Thank you.
in the source code there goes
"/usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.3/lib/action _dispatch/http/request.rb" 257L, 8741C
def ip
@ip ||= super
end
# Originating IP address, usually set by the RemoteIp middleware.
def remote_ip
@remote_ip ||= (@env["action_dispatch.remote_ip"] || ip).to_s
end
but I really don't know the implications.
request.ip
returns the client ip
even if that client is a proxy.
request.remote_ip
is smarter and gets the actual client ip
. This can only be done if the all the proxies along the way set the X-Forwarded-For header.