Saim
Saim

Reputation: 2523

Multi-level Subdomains in Rails

Can we have multi-level subdomain in Rails like this?

sub1.sub2.mysite.com

Upvotes: 0

Views: 1402

Answers (2)

Roger Ertesvag
Roger Ertesvag

Reputation: 1794

Yes, you can check the subdomain the app is accessed from using request.subdomains

But if you are going to do something more advanced you should probably use subdomain-fu

Upvotes: 2

Mark Connell
Mark Connell

Reputation: 3749

I don't see any reason why you couldn't have a subdomain of a subdomain being used in a rails app.

You'll want to setup a wildcard A record in your domain DNS and configure your http server to accept wildcard server aliases.

Then in your application_controller you'll probably want a before_filter that does some juju with

request.host

to do whatever you want, be it

Account.find_by_domain(parsed_request_host) or whatever.

Upvotes: 0

Related Questions