views:

156

answers:

1

When using a catch all route the URLs have the forward slash encoded as %2F which means I can not lookup a record using request.path

map.document '*path', :controller => 'documents', :action => 'show'

Page.find_by_permalink('/blog/my_first_post') # Record found
Page.find_by_permalink('blog%2Fmy_first_post') # Record not found

Firstly why is this encoding happening, and secondly is there a way to turn it off?

PS. I know I could decode request.path before using in the find but I would prefer a pretty URL.

A: 

try renaming your glob variable to request_path and use params[:request_path], I do a similar thing and I've never had this problem. however, I believe I snip off the end and search by slug, then do a comparison of the path to what I believe it should be.

Derek P.
The param is return as an array so all you need to do is params[:path].join('/')
Kris