Hello. This is my first post to the forum so I''ll give a little introduction. I am currently at university in guildford, uk. I''m learning ruby on rails on the side of my course and currently building an application to display events, blog posts, and various info for a diversity training organisation. My problem is in using the routes. What I want is to have is: for the normal user viewing the website, they should visit: domainname/:team_name/:action/:id the organisation has seperate teams and the info on the screen needs to be for one team at a time, the first page will have a team selection page. it will search for the :team_name in the database and filter all subsequent information for this team. All of the public site viewing goes through the same controller (:siteview). There is then an admin side which is made up of lots of different controllers (one for each type of data) and I would like the url to be of the form: domainname/admin/:controller/:action/:id I''m going round in circles with it now. At the moment I can only get either the public site OR the admin site to work at once: for the admin: map.connect ''admin/:controller/:action/:id'' but then the link_to bits in the public pages make links including the full controller in the page. for the public site: map.connect '':team_name/:action/:id'' but then now the admin pages get processed through the public site controller. I have tried convoluted ways to make the public site controller to recognise the ''admin'' special word and redirect to admin pages but that doesn''t resolve link_to issues and seems overly complicated. I am sure there is a far neater solution and I am willing to change the structure of my urls if it makes it easier (I could change my controller structure too but that would involve more work and so I would prefer not to). Thanks for any help you can offer me. Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Try this: map.connect ''admin/:controller/:action/:id'' map.connect '':team_name/:action/:id'', :controller => "siteview" 1) The Route for the admin part has to be before the other map in the routes file, otherwise the other route would match also for /admin/... and look for a team called "admin" (btw: you should prevent creation of a team called "admin" as that would never be able tothe public views...) 2) you have to specify the controller for the :team_name route ... Hope that helps, maybe you could give more info if not... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Thorsten L wrote:> Try this: > > map.connect ''admin/:controller/:action/:id'' > > map.connect '':team_name/:action/:id'', :controller => "siteview" >the problem with this is that when I used a link_to tag in the siteview area the link that is made uses the first route, eg. domainname/admin/siteview/course/3 instead of domainname/someteam/course/3 ta -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
stupid me, you''re right... well you would have to setup individual routes for each admin controller: map.connect ''admin/users/:action/:id'', :controller => ''users'' map.connect ''admin/teams/:action/:id'', :controller => ''teams'' etc. pp. don''t see any other solution, but i''m no pro either :-D --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Thorsten L wrote:> stupid me, you''re right... well you would have to setup individual > routes for each admin controller: > > map.connect ''admin/users/:action/:id'', :controller => ''users'' > map.connect ''admin/teams/:action/:id'', :controller => ''teams'' > etc. pp. > > don''t see any other solution, but i''m no pro either :-Dits inelegant but it will work and its more important for me to get the site working than have perfect elegance. cheers! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---