正如标题所示,您可以使用这两种方法获取客户端的IP.我想知道是否有任何差异.谢谢.
在源代码中有
"/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
Run Code Online (Sandbox Code Playgroud)
但我真的不知道其含义.