Auto detect URL

Is it possible to read the URL that someone uses to access your site.
For example: I own, www.english.com and www.chinese.com and only have
one rails site. Is it possible, when a user accessing my rails site from
english.com is automatically set to use my English I18n, as well as a
separate style sheet, where as www.chinese.com would utilize chinese
I18n ??

On Fri, Dec 12, 2008 at 5:08 PM, Richard S.
[email protected] wrote:

Is it possible to read the URL that someone uses to access your site.
For example: I own, www.english.com and www.chinese.com and only have
one rails site. Is it possible, when a user accessing my rails site from
english.com is automatically set to use my English I18n, as well as a
separate style sheet, where as www.chinese.com would utilize chinese
I18n ??

Hi Richard, yes it’s possible. I have a rails app that can be accessed
from various domains, what I do is check request.host to get the
domain.


Jaime I.
http://jaimeiniesta.com
http://www.workingwithrails.com/person/6722-jaime-iniesta

Hey thanks for the heads up!!!

For anyone else who wants to implement this, you can just put

<%= request.host %> in your view or
request.host in your controller

if you are looking at your site from http://0.0.0.0:3000 you will get a
return of:

0.0.0.0

Thanks Jaime !!