I have google map web application on rails. google map needs API key that depends on server address. ex) example.com:3000 and example.com:4000 need different API key I have API key for several addresses in database example.com:3000 [some key] example.com:4000 [some key] localhost:3000 [some key] 192.168.0.17:3000 [some key] I want to select proper key based on server address when server start up Now I am manually changing API keys everytime I need to do. #1 Is there any way to get server address (rails server itself)? #2 Can this work be done when server startup? not every session? Thank you sean -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Answering the question #1 you can achieve this using the request.env[ ''HTTP_HOST'' ] variable, that will return you a string with the hostname and the listening port, something like ''localhost:8080''. For the second one, I guess you could create like some constants for storing those keys of your needs, but you''re not being very clear so I can not go further. Hope this can help you. Carlos. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.