Hello, Is there a way to get Rails to ignore a leading-directory in a URL (either in the environment.rb or routes.rb file)? For example, I''d like all requests to: http://domain.com/blah/products to get processed as [app]/products I don''t have access to use mod_redirect, and right now Rails keeps looking at "blah" to be a controller. I''d simply like it always stripped out of the URL. Any suggestions? Thank you! -Jason --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
that''s not a leading directory, it''s the rails routing path which follows the convention :controller/:action/:id. Say you were to strip out the controller portion and all you have are actions, which controller will these actions execute in? And what if you have two controllers with the same name, how will rails disambiguate between the two actions. Or say you wanted to get rid of the action name and just have a controller name? Then what action should be called? If you want to use the format: myapp.com/products (shows index page) myapp.com/products/1 (shows details for product with id 1) myapp.com/products/1/edit (shows edit screen for product with id 1) then look into using restful routes. Mike On 2/29/08, Jason Crystal <jcrystal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello, > > Is there a way to get Rails to ignore a leading-directory in a URL > (either in the environment.rb or routes.rb file)? > > For example, I''d like all requests to: http://domain.com/blah/products > to get processed as [app]/products > > I don''t have access to use mod_redirect, and right now Rails keeps > looking at "blah" to be a controller. I''d simply like it always > stripped out of the URL. > > Any suggestions? Thank you! > > -Jason > > >--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for your reply! Perhaps I wasn''t clear. The web server is prefixing all Rails-bound requests with /blah, and it provides no additional information to the app. So, myapp.com/products/1/edit would COME IN to rails as myapp.com/blah/ products/1/edit I''d like to eliminate that leading directory ("blah", in the above example) Thanks, -Jason On Feb 29, 3:29 pm, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> that''s not a leading directory, it''s the rails routing path which > follows the convention :controller/:action/:id. Say you were to strip > out the controller portion and all you have are actions, which > controller will these actions execute in? And what if you have two > controllers with the same name, how will rails disambiguate between > the two actions. Or say you wanted to get rid of the action name and > just have a controller name? Then what action should be called? > > If you want to use the format: > > myapp.com/products (shows index page) > myapp.com/products/1 (shows details for product with id 1) > myapp.com/products/1/edit (shows edit screen for product with id 1) > > then look into using restful routes. > > Mike > > On 2/29/08, Jason Crystal <jcrys...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hello, > > > Is there a way to get Rails to ignore a leading-directory in a URL > > (either in the environment.rb or routes.rb file)? > > > For example, I''d like all requests to:http://domain.com/blah/products > > to get processed as [app]/products > > > I don''t have access to use mod_redirect, and right now Rails keeps > > looking at "blah" to be a controller. I''d simply like it always > > stripped out of the URL. > > > Any suggestions? Thank you! > > > -Jason--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
(Rails keeps trying to interpret the "blah" as a controller, when in fact it should be ignored) On Feb 29, 3:38 pm, Jason Crystal <jcrys...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for your reply! > > Perhaps I wasn''t clear. > > The web server is prefixing all Rails-bound requests with /blah, and > it provides no additional information to the app. > > So, myapp.com/products/1/edit would COME IN to rails as myapp.com/blah/ > products/1/edit > > I''d like to eliminate that leading directory ("blah", in the above > example) > > Thanks, > -Jason > > On Feb 29, 3:29 pm, "Mike Garey" <random...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > that''s not a leading directory, it''s the rails routing path which > > follows the convention :controller/:action/:id. Say you were to strip > > out the controller portion and all you have are actions, which > > controller will these actions execute in? And what if you have two > > controllers with the same name, how will rails disambiguate between > > the two actions. Or say you wanted to get rid of the action name and > > just have a controller name? Then what action should be called? > > > If you want to use the format: > > > myapp.com/products (shows index page) > > myapp.com/products/1 (shows details for product with id 1) > > myapp.com/products/1/edit (shows edit screen for product with id 1) > > > then look into using restful routes. > > > Mike > > > On 2/29/08, Jason Crystal <jcrys...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello, > > > > Is there a way to get Rails to ignore a leading-directory in a URL > > > (either in the environment.rb or routes.rb file)? > > > > For example, I''d like all requests to:http://domain.com/blah/products > > > to get processed as [app]/products > > > > I don''t have access to use mod_redirect, and right now Rails keeps > > > looking at "blah" to be a controller. I''d simply like it always > > > stripped out of the URL. > > > > Any suggestions? Thank you! > > > > -Jason--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jason Crystal wrote:> Hello, > > Is there a way to get Rails to ignore a leading-directory in a URL > (either in the environment.rb or routes.rb file)? >> > Any suggestions? Thank you! > > -Jasonin your config/routes.rb map.connect ''blah/:controller/:action/:id'' hth ilan -- 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?hl=en -~----------~----~----~----~------~----~------~--~---