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
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
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
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,
<%= link_to type.name, types_path(CGI::escape(type.name)) %>
You mentioned the second one gave a “no route” error, but did this one?
just did a quick test and this actually worked for me). Just curious.