Virtual subdomains?

I have an application where many subdomains will exist depending upon
geographic location ( and,
but all subdomains will use the same code, only have different data.
Is there a way to handle subdomains virtually with RoR or will it be
necessary to copy the same code to each hard coded subdomain?

The account_location plugin ( will help you out for your subdomain handling, I’m using it in almost all my apps. Then you’ll need to use a wildcard DNS entry so that the nameserver will pass any url belonging to the domain to your rails webserver (*

There are a few way to go at this:

  1. Keep all your data in one database and filter out the data for your each of the locations

  2. Use the location to set the database connection in your application controller so that you can use a separate database for each customer

Best regards

Peter De Berdt