Forum: Ruby on Rails get subdomain in localhost

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bcc578efe3bb69e763ec7695d675c06a?d=identicon&s=25 Srinath A. (srinathbtech)
on 2009-02-13 12:32
Hi,
I was wondering how to get subdomain name in my localhost.
I'm on ubuntu and set domainnames in /etc/hosts like this

127.0.0.1 : localhost
127.0.0.1 : tokyo
127.0.0.1 : sub.tokyo

when i was using puts request.domain it was showing "tokyo" when hit URL
with http://tokyo:3002 and "sub.tokyo" when hit URL with
http://sub.tokyo:3002


then, how i can i differ subdomains in sub.tokyo
i tried using request.subdomains.first, but showing nil in localhost

Finaly i was looking for these when used
 puts request.domain.inspect
 ===>  "localhost" or "tokyo"
 puts request.subdomains.first
 ===> "sub"

any help??

thanks,
sri..
A82ba1167f4d4a8d1de63820e576a87f?d=identicon&s=25 Robby Russell (Guest)
on 2009-02-13 15:26
(Received via mailing list)
This might help you out.

http://www.robbyonrails.com/articles/2009/01/11/su...

Cheers,
Robby

On Fri, Feb 13, 2009 at 3:32 AM, Srinath A.
<rails-mailing-list@andreas-s.net> wrote:
> with http://tokyo:3002 and "sub.tokyo" when hit URL with
>  ===> "sub"
>
> any help??
>
> thanks,
> sri..
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>



--
Robby Russell
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://planetargon.com/
http://robbyonrails.com/
http://twitter.com/planetargon
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]
This topic is locked and can not be replied to.