Rails Subdomains With Authentication

February 27, 2010

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.

User management and authentication is implemented using the Devise gem. The subdomain_routes gem implements subdomains and routing.

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:

http://github.com/fortuity/subdomain-authentication

A complete walkthrough tutorial is available on the GitHub wiki. The tutorial documents each step I followed to create the application:

View the Tutorial

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”.

Advertisements

Looking for a Rails Example App

February 17, 2008

I’m about to start a new development project. For my beginning point, I’d like to use a well-thought-out “best practice” open source Rails web application.

I’m not aware of any open source Rails app that completely matches my requirements. I’m looking for an app that was developed in Rails 2.0, implements a RESTful architecture, and uses RSpec for specifications/testing. And optimally, it would already have authentication and authorization worked out using the restful_authentication plugin.

I’m going to start searching and see what I find.