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@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.

Search Discussions

  • Dave Aronson at Nov 30, 2011 at 7:08 pm

    On Wed, Nov 30, 2011 at 04:00, johnnybutler7 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.
  • Koulikoff at Dec 1, 2011 at 6:00 am
    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 wrote:
    On Wed, Nov 30, 2011 at 04:00, johnnybutler7 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@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.
  • Johnnybutler7 at Dec 1, 2011 at 8:40 am
    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 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 wrote:


    On Wed, Nov 30, 2011 at 04:00, johnnybutler7 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@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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 30, '11 at 9:00a
activeDec 1, '11 at 8:40a
posts4
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase