Ruby on Rails Wednesday, November 30, 2011

On Wed, Nov 30, 2011 at 04:00, johnnybutler7 <johnnybutler7@gmail.com> wrote:

> 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

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. :-)

-Dave

--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment