Custom account subdomains with Rails 3


I needed to handle custom account subdomains with Rails and I wrote a
simple rack middleware for that
It works by mapping any subdomain to given PATH. For example when user
hits and mapping is /users/:subdomain, it
will map the request to

I accomplished it with rack middleware, cause I wanted to have this
mechanism also for Rails 2.x.

The thing is, I don't want to duplicate stuff that's already in
router, so here is my question: is there any way to do such mapping
with Rails 3 router? Or maybe a better way to handle custom account



Have a look at this article: