I''ve got a route: map.find_stuff "/find_stuff/:near", :controller => "find_stuff", :action => "show" Where the :near portion is user specified, so when users enter a place with a period, the route doesn''t match correctly. So I change it to this: map.find_stuff "/find_stuff/:near", :near => /[^?]*/, :controller => "find_stuff", :action => "show" This works correctly, the route will grab everything up to the question mark if there is one and put it into the near param. So my problem now is using the route helpers. If a user specifies a :near parameter of "aa?aa" and I pass that in as: find_stuff_path(:near => ''aa?aa'') it fails, because a near with a question mark is invalid. If I pass it in already escaped: find_stuff_path(:near => ''aa%3Faa'') the route helper escapes the path itself and I end up with: ''/find_stuff/aa%253Faa'' where the % has been re-escaped and this does not yield the original value when I get the value out of the params. Is there any clean way to solve this problem? Is this a bug where the route segment validation should happen after the escaping instead of before? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Apr 1, 2009 at 7:02 AM, Joseph Palermo <jpalermo@pivotallabs.com> wrote:> > I''ve got a route: > map.find_stuff "/find_stuff/:near", :controller => > "find_stuff", :action => "show" > > Where the :near portion is user specified, so when users enter a place > with a period, the route doesn''t match correctly. So I change it to > this: > map.find_stuff "/find_stuff/:near", :near => /[^?]*/, :controller => > "find_stuff", :action => "show" > > This works correctly, the route will grab everything up to the > question mark if there is one and put it into the near param.Does it work correctly even without the ? option? (i.e. :near=>/./). Then the helpers should escape the value correctly and generate URLs which can be recognized correctly. The current behaviour is ''intentional'', because you''re meant to get a routing error out the other side when you try to generate a route which wouldn''t be ''round trippable''. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---