Address server

Hi
Do you know a method for find address of the server ?
I have to do an “if” to find if I am in localhost:3000 or in

Thank you an happy new year.
Marco

On 02.01.2007 14:19, marco wrote:

Do you know a method for find address of the server ?
I have to do an “if” to find if I am in localhost:3000 or in
mydomain.com

In what kind of application?

robert

In a web application

On 02.01.2007 15:11, marco wrote:

In a web application

Often you can get this information from the URL of the current page.

Other than that you can derive this from the socket if you have access
to it:

http://ruby-doc.org/stdlib/libdoc/socket/rdoc/classes/Socket.html#M002385

And, please don’t top post. Thank you!

Kind regards

robert

I’m going to make the assumption that we are talking about a Rails app.
The
easiest way I found was to call request.host_with_port within a
controller
or a view. This will return the host name and the port number (if
provided).

I use this approach to figure out which Google Maps api key to use in my
application (one for development work, another one for the “production”
site).

There is a very active mailing list for Ruby on Rails. You can get
details
on how to subscribe by going to
http://groups.google.com/group/rubyonrails-talk?hl=en .

Hope this helps.

Fred

“marco” [email protected] writes:

I’m suspecting your asking the wrong question. Can you expand a bit more
on
what exactly you need to do and/or why you need to know this. Also, are
you
talking about working this out from the client perspective or from
within your
code on the server?

Tim

Frederic J. wrote:

I’m going to make the assumption that we are talking about a Rails app. The
easiest way I found was to call request.host_with_port within a controller
or a view. This will return the host name and the port number (if provided).

I use this approach to figure out which Google Maps api key to use in my
application (one for development work, another one for the “production”
site).
Me too. This was my trouble.

There is a very active mailing list for Ruby on Rails. You can get details
on how to subscribe by going to
http://groups.google.com/group/rubyonrails-talk?hl=en .

Hope this helps.

Fred

I find this method “request.env” who return a hash of all information :
request.env[“SERVER_NAME”] and [“SERVER_PORT”]

Thank for your helps
Marco