2013-07-12 47 views

回答

6

我想通了!

這裏我把我的ApplicationHelper的方法:

def remote_hostname 
    require 'resolv' 
    Resolv.getname(request.remote_ip) 
end 

就這麼簡單!

-1

請嘗試以下操作;

require 'socket' 
host = Socket.gethostname 

或者你可以簡單地做;

`hostname`.strip # Get the hostname from the shell and removing trailing \n   
+1

我認爲他是*遠程*主機名後,而不是本地的。 –

相關問題