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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, Nov 30, 2011 at 04:00, johnnybutler7 <johnnybutler7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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}/newsSounds 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 On Nov 30, 11:07 pm, Dave Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> wrote:> On Wed, Nov 30, 2011 at 04:00, johnnybutler7 <johnnybutl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > What im trying to do at the moment is have the client name after > > the .com/ so its always presentwww.myurl.com/client_nameso 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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. :( On Dec 1, 5:59 am, koulikoff <koulik...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > On Nov 30, 11:07 pm, Dave Aronson <googlegroups2d...-BRiZGj7G2yRXqviUI+FSNg@public.gmane.org> > wrote: > > > > > On Wed, Nov 30, 2011 at 04:00, johnnybutler7 <johnnybutl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > What im trying to do at the moment is have the client name after > > > the .com/ so its always presentwww.myurl.com/client_namesoi 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.