I have a ruby application named "addressbook" and I can access it like: http://localhost:3000/addressbook/ what i''d like to do is also allow it to be accessed like: http://localhost:3000/foo/addressbook/ http://locahost:3000/bar/addressbook/ I know I can something like this with Routes via: map.connect ''foo/:controller/:action/:id'' map.connect ''bar/:controller/:action/:id'' map.connect '':controller/:action/:id'' The problem is the links in the resultant views. If I go to http://localhost:3000/bar/addressbook All my links will look like: /foo/addressbook/show/1 when I really want them to look like: /bar/addressbook/show/1 _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Dean Holdren
2005-Nov-03 17:17 UTC
Re: can routes remember a URI prefix? i.e. /prefix/myapp/
well it looks like I solved my own problem :) with routes.rb like: map.connect '':context/:controller/:action/:id'' map.connect '':controller/:action/:id'' I can do requests like: http:/localhost:3000/addressbook/ http:/localhost:3000/foo/addressbook/ http:/localhost:3000/bar/addressbook/ http:/localhost:3000/anything/addressbook/ and they all work, and the responses have links that match the request. i.e. a request to http://localhost:3000/foo/addresbook has links like: "/foo/addressbook/show/1" I guess it puts the "/foo" or "/bar" into a variable named "context" and it remembers it somehow when links are generated with link_to? I gotta look at the code for routes and link_to. this is pretty interesting functionality. On 11/2/05, Dean Holdren <deanholdren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a ruby application named "addressbook" and I can access it like: > > http://localhost:3000/addressbook/ > > what i''d like to do is also allow it to be accessed like: > > http://localhost:3000/foo/addressbook/ > http://locahost:3000/bar/addressbook/ > > I know I can something like this with Routes via: > > map.connect ''foo/:controller/:action/:id'' > map.connect ''bar/:controller/:action/:id'' > map.connect '':controller/:action/:id'' > > The problem is the links in the resultant views. > If I go to http://localhost:3000/bar/addressbook > > All my links will look like: /foo/addressbook/show/1 > when I really want them to look like: /bar/addressbook/show/1_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails