Dynamic VHosts One-liner for Rails #
So, how do Tada and Basecamp do dynamic virtual hosts to give each user their own subdomain? Drop this in ApplicationController:
before_filter { |c| c.account =
Account.find_by_subdomain(c.request.subdomains.first) }
Bravo. Requires a ServerName *.tadalist.com in the Apache VHost configuration and an accounts table with a subdomain field. (seen among #rubyonrails quotes.)
Update: If you’re struggling to get this to work, mpet45 has more. Configuring DNS and all that.


