address server

M

marco

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
 
R

Robert Klemme

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
 
M

marco

Frederic said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,137
Members
47,754
Latest member
Armand37T7

Latest Threads

Top