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