FOR RAILS 3.0: See my Github repo for a complete example implementation of Rails 3 subdomains with authentication (including a detailed tutorial). It’s much easier to implement subdomains in Rails 3 than in Rails 2.3. Still there’s a few tricks to solve some common problems which you can see in the new example.
FOR RAILS 2.3:
I’ve released an open source application for Rails 2.3 that shows how to integrate subdomains with authentication.
You can use this project as a starting point for any Rails web application that requires subdomains and authentication. You can easily customize the application for your own needs.
You can obtain the source code here:
A complete walkthrough tutorial is available on the GitHub wiki. The tutorial documents each step I followed to create the application:
This application implements a particular scenario where subdomains are required. There is a “main” domain where anyone can visit and create a user account. There is an “admin” subdomain for the exclusive use of administrators. And registered users can create any number of subdomains which could host blogs or other types of sites. This approach is familiar to users of sites such as wordpress.com and can be called “blog-style subdomains in Rails”.