Q:

Subdomain instead of permalink

I'm looking for a way to use subdomains as a permalink in rails.
For example:
Instead of http://domain.com/user2 pointing to user2's profile. 
I would like http://user2.domain.com to point to user2's profile.
Anyone know of a solution to this that will work on heroku?

A:

Routes:
  get '/' => 'home#index', :constraints => { :subdomain => 'www' } 
  get '/' => 'users#show', :constraints => { :subdomain => /.+/ } 

Users Controller:
@user = User.find_by_permalink(request.subdomain)

