Also, I noticed that even spaces are not being escaped with the below: <%= link_to type.name, types_path(CGI::escapeHTML(type.name)) %>
The link is rendered with a space in it. Once I click on it, it is eventually rerouted to the same address except with the space escaped with a %20. That does not seem like the intended behavior? On May 27, 8:46 pm, Kendall Gifford <[email protected]> wrote: > On Friday, May 27, 2011 3:41:00 PM UTC-6, tashfeen.ekram wrote: > > > actually, it is not a resource route. it is a route that is > > specifically defined. that is there is not resource "type." > > > match "/types/:types" => "browse#list", :as => :types > > > It is unresourceful route. > > If this is your route, as long as you don't have other routes that begin > with "/types/..." then you could update it with a constraint that allows > forward slashes: > > > match "/types/:types" => "browse#list", :types => /.*/, :as => :types > > This should both make the routes match correctly on incoming URLs _and_ > allow you to call: types_path("text/with/slashes") without any errors being > raised. > > Of course, you should adjust the constraints regexp as is appropriate (I > find it ugly/hackish to have it wide open like that except where it would > truly make sense). Also, if you had other routes like: > > > match "/types/sub/directory/:id" => "browse#yourmom", :as => :your_mom > > Then it'd conflict using the wide-open constraint technique. > > Anyhow, if you absolutely insist on simply escaping slashes instead of > adding a constraint to your route, what was wrong with your first, original > example: > > > <%= link_to type.name, types_path(CGI::escape(type.name)) %> > > You mentioned the second one gave a "no route" error, but did this one? (I > just did a quick test and this actually worked for me). Just curious. -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

