client name embedded in the url (not subdomains)

Hi,

I have already used subdomains in rails 3 and it was straightforward
to setup.

What im trying to do at the moment is have the client name after
the .com/ so its always present www.myurl.com/client_name so i can
grab who the client is and use that throughout their session.

localhost:3000/{client_1}/news
localhost:3000/{client_2}/news

I have searched around and cant really find any examples of this so im
wondering if its possible and/or good practice. I would prefer the
subdomain route but the client specifically wants it setup this way
and im not really sure how best to do it, any advice is appreciated,

JB

Sounds like a job for Superman, er, I mean, a custom route. Maybe
something like:

  match ':client(/:controller(/:action(/:id(.:format))))'

based on the old wildcard router (adding :client at the front). Note
that, as advised in the modern default route.cfg files, this will make
ALL your controllers and actions accessible via GET! If you're OK
with that, go for it. Also depending on how the rest of your normal
routes look (in particular whether you're using nested resources,
renamed routes, etc.), you may need more such lines, which could get
to be a pain.

If you decide to try it, let me know how it works. :slight_smile:

-Dave

1. I wander why the standard way of keeping the user data in the
session does not fit you.
2. scope "(:username)", :username => /[-a-zA-Z]/ do <other routes>
end should help

Thanks guys, ill give those a go. I have different namespaces, nested
resources etc so im not expecting it to be straight forward. Its not
about keeping the user data in the url, its more about personalising
the url to the client so it has their name in it and some branding on
the front end. Personally i would go down the subdomain route but the
client im developing it for wants it this way. :frowning: