Getting Local Hostname

How can I get the local hostname in Rails? Or Ruby for that matter.

Thanks in advance.

Joe S. wrote:

How can I get the local hostname in Rails? Or Ruby for that matter.

Cheat:

me = hostname

Note the backticks ``

If that don’t work, cheat harder.


Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!

On Mon, 18 Dec 2006 16:59:41 +0100
Joe S. [email protected] wrote:

How can I get the local hostname in Rails? Or Ruby for that matter.

Thanks in advance.

In Rails, there is request.host or request.host_with_port that you can
use in your controllers.

or better yet

in rails:

ENV[“HOSTNAME”]

Chris