Rails获取客户端IP地址
Example Rails Code
In RAILS_ROOT/app/controllers/show_my_ip_controller.rb :
view plain copy to clipboard print ?
class ShowMyIpController < ApplicationController def index @client_ip = request.remote_ip end endIn RAILS_ROOT/app/views/show_my_ip/index.html.erb :
Your IP address is < %= @client_ip % >
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did42974