Is it possible to map a subdomain to a resource? I have a company model. Currently, using subdomain_fu, my routing file contains:
map.company_root '', :controller => 'companies', :action => 'show',
:conditions => { :subdomain => /.+/ }
My Company model contains a “subdomain” column.
Whilst this works as intended, it’s a named route and isn’t restful. Essentially, I need to map “name.domain.com” to the show action for the companies controller. Is a named route the way to go, or can I use a resource route?
I don’t know of a way to do this with
map.resources. It does accept a:conditionsoption but I’m not sure how to remove the/companies/portion of the URL. However,map.resourcesis primarily a convenient way to generate a bunch of named routes, which you can do manually. Something like this.Untested, but it should get you close.