For legacy reasons, I''d like to be able to have part of a url as optional, the problem is that it''s at the start of the URL, rather than the end. /laddr/match/result with ''/laddr'' being optional, depending on which URL the user uses to access the site. Is it possible to do this with routes? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Stuart Grimshaw wrote:> For legacy reasons, I''d like to be able to have part of a url as > optional, the problem is that it''s at the start of the URL, rather > than the end. > > /laddr/match/result > > with ''/laddr'' being optional, depending on which URL the user uses to > access the site. > > Is it possible to do this with routes?of course, everything is possible with RubyonRails, don''t make this mistake and ask such a question again :P *just kidding* map.connect /:option/match/result, :controller => "something", :action => "methodname", :option => /.*/ Try that :D -- 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 -~----------~----~----~----~------~----~------~--~---
On Sep 9, 1:31 pm, Jamal Soueidan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Is it possible to do this with routes? > > of course, everything is possible with RubyonRails, don''t make this > mistake and ask such a question again :P *just kidding*heh :-)> map.connect /:option/match/result, :controller => "something", :action > => "methodname", :option => /.*/ > > Try that :DCool, that works, in most cases. Just need to figure out the accompanying apache rewrite rules to serve any actual files from te directory, instead of pointing them at mongerl. Cheers Jamal ... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Stuart Grimshaw wrote:> On Sep 9, 1:31 pm, Jamal Soueidan <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> > Is it possible to do this with routes? >> >> of course, everything is possible with RubyonRails, don''t make this >> mistake and ask such a question again :P *just kidding* > > heh :-) >You are welcome Stuart :D -- 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 -~----------~----~----~----~------~----~------~--~---
So, while this works great on the productions server (Apache2 + mongrel_cluster) it causes a few problems when running on the dev machine. Can I have a seperate set of routes for the dev box? or am I missing something? This is what is surrently in my routes.rb : map.connect ''/:option'', :controller => "welcome", :option => /laddr/ map.connect ''/:option/:action/:defender_id/ ladder/:ladder_id'', :controller => ''ladder'', :option => /laddr/ map.connect ''/:option/match/refuse/:id'', :controller => ''match'', :action => ''refuse'', :option => /laddr/ map.connect ''/:option/match/result/:id'', :controller => ''match'', :action => ''result'', :option => /laddr/ map.connect ''/:option/match/:match_id/:action/:id'', :controller => ''match'', :option => /laddr/ # Install the default route as the lowest priority. map.connect ''/:option/:controller/:action/:id.:format'', :option => / laddr/ map.connect ''/:option/:controller/:action/:id'', :option => ''/laddr/'' The optional bit, doesn''t seem to be optional, so if I do http://localhost:3000/ I get an error : "no route found to match "/" with {:method=>:get}" but when I add the /laddr it works fine. I can live with that, but it also breaks static files, stylesheets and images for example, as it''s now looking for those in /laddr/stylesheets I don''t really like the idea of having 2 sets of routes, because, well, I only want to maintain 1 and not forget about the production ones all the time (because you know that''s what will happen). -S --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sep 17, 8:16 pm, Stuart Grimshaw <stuart.grims...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So, while this works great on the productions server (Apache2 + > mongrel_cluster) it causes a few problems when running on the dev > machine. > > Can I have a seperate set of routes for the dev box? or am I missing > something? > > This is what is surrently in my routes.rb : > > map.connect ''/:option'', :controller => "welcome", :option => /laddr/ > > map.connect ''/:option/:action/:defender_id/ > ladder/:ladder_id'', :controller => ''ladder'', :option => /laddr/ > map.connect ''/:option/match/refuse/:id'', :controller => > ''match'', :action => ''refuse'', :option => /laddr/ > map.connect ''/:option/match/result/:id'', :controller => > ''match'', :action => ''result'', :option => /laddr/ > map.connect ''/:option/match/:match_id/:action/:id'', :controller => > ''match'', :option => /laddr/ > > # Install the default route as the lowest priority. > map.connect ''/:option/:controller/:action/:id.:format'', :option => / > laddr/ > map.connect ''/:option/:controller/:action/:id'', :option => ''/laddr/'' > > The optional bit, doesn''t seem to be optional, so if I dohttp://localhost:3000/ > I get an error : > > "no route found to match "/" with {:method=>:get}" > > but when I add the /laddr it works fine. I can live with that, but it > also breaks static files, stylesheets and images for example, as it''s > now looking for those in /laddr/stylesheets > > I don''t really like the idea of having 2 sets of routes, because, > well, I only want to maintain 1 and not forget about the production > ones all the time (because you know that''s what will happen).I''m still stuck with this if anyone has any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---