Using subdomain names in routes?


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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs