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
mydomain.com

Thank you an happy new year.
Marco

In what kind of application?

  robert

···

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 a web application

···

On Jan 2, 2:34 pm, Robert Klemme <shortcut...@googlemail.com> wrote:

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.comIn what kind of application?

        robert

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

···

On 02.01.2007 15:11, marco wrote:

In a web application

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

···

On 1/2/07 7:15 AM, "marco" <marco.burlando@gmail.com> wrote:

In a web application

On Jan 2, 2:34 pm, Robert Klemme <shortcut...@googlemail.com> wrote:

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.comIn what kind of application?

        robert

--
Frederic Jean
fred@fredjean.net
http://typo.fredjean.net/

"marco" <marco.burlando@gmail.com> writes:

In a web application

> 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.comIn what kind of application?

        robert

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

···

On Jan 2, 2:34 pm, Robert Klemme <shortcut...@googlemail.com> wrote:

On 02.01.2007 14:19, marco wrote:

--
tcross (at) rapttech dot com dot au

Frederic Jean 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