Reputation: 56729
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 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?
Upvotes: 1
Views: 169
Reputation: 20687
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:
# If you're using Apache, something like:
ServerAlias *.orion.com
Then, you can use the subdomain-fu
gem 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:
link_to 'Posts', post_path(@post, :subdomain => 'johnny')
johnny.orion.com/posts/4
Upvotes: 1