Sunday, September 23, 2007

subdomains in Rails




You can find the host of the current domain in Rails with:

@request.host

If you want to find the subdomain, Rails nicely parses this out for
you in an array called subdomains.

So, if you had a hostname like "pr.sunshine.sness.org", you could get
the "pr" by going

@request.subdomains[0]