I would like to have my users specify custom URL paths such that those paths are placed in front of my site’s name, i.e. if I have a site called http://www.orion.com, I’d like a user to be able to create his own little home page at johnny.orion.com.
I have successfully managed to implement orion.com/johnny, which works implemented by adding map.connect ‘:path’ at the end of my routes then making sure the path variable is present when needed.
How can I get johnny.orion.com to function?
First, you’ll need to set up wildcard DNS – so that the subdomains actually resolve to somewhere.
Then, configure your virtual host to accept connections from these subdomains:
Then, you can use the
subdomain-fugem to handle your routes within Rails. Have a look at the associated Railscast for some good tips.The syntax for the gem is something like this: