Forum: Ruby on Rails Using subdomain names in routes?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Matt Jankowski (Guest)
on 2006-01-17 03:01
(Received via mailing list)

We want to use the name field of our Market object for URLs like...

...and other similar URLs, basically using the subdomain as a key for
the app to know which Market (there is a markets table where the
subdomain field corresponds to to use.  In this example,
both pages are viewing the group homepage for 'groupname' group.  There
could conceivably be a group called 'groupname' in both the 'foo' and
'bar' market.  We COULD use /group/view/id, but using the name makes me

I'm aware of using filters in application.rb to use the subdomain as a
key, and I could then access @market throughout the app to figure out
where I am, but it would also be nice to have some rule that sends all
URLs that have a subdomain to a 'markets' controller, for example.

Does this make sense?  I think the basic question is can you do things
with subdomains in routing, instead of just using the filter in
application.rb to set variables that your controllers handle?...

This topic is locked and can not be replied to.