RESTful unique subdomains

Does anyone know the best way to handle arbitrary sub domains based on
user selection RESTfully?

In other words, in our app we’re going to let the user select a sub
domain, and need that to resolve to our main Rails app and use that as
the key for their account. Navigating to the subdomain
( will call the show action of the account

And we’re going to be using RESTful routes as well. Is there a plugin
perhaps? The request_routing plugin doesn’t seem to work with REST, and
I’m not sure if that’s the best fit for this.

Thanks for any help.