Hi there, My routes.rb is something like map.connect '':controller/:action/:id'' However, when a url request likes http://xxx/user/category/a/b My intension is to call :controller => ''user'' :action => ''category'' :id => ''a/b'' However, :id has slash in it (a/b) will make rails fail to route. (apache fail, webrick works fine somehow) It seems like rails will try to match route rule with map.connect :controller/:action/:id/:others but failed. I know one solution is to call CGI.escape in link_to or url_for , like link_to :controller => ''user'', :action => ''category'', :id => CGI.escape (category) and unescape when I got it. category = CGI.unescape(params[:category]) Any better solution ? Thanks. Gary -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060531/5cb9329b/attachment.html
Alex Wayne
2006-May-31 06:52 UTC
[Rails] Re: url parameter :id with slash (/) failed to route
Gary Lin wrote:> Hi there, > > My routes.rb is something like > > map.connect '':controller/:action/:id'' > > However, when a url request likes > http://xxx/user/category/a/b > > My intension is to call > :controller => ''user'' > :action => ''category'' > :id => ''a/b'' > > However, :id has slash in it (a/b) will make rails fail to route. > (apache fail, webrick works fine somehow) > Thanks. > > GaryRails routes really don''t like to do that. I would recommend coming up with a diiferent way to handle those id''s that doesn''t require a slash. -- Posted via http://www.ruby-forum.com/.
Maybe Matching Threads
- Re: url parameter :id with slash (/) failed to route
- How to Auto Add forward slash "/" when accessing a link/url through ProxyPass
- DirHandler in surplus slashing / unrequited unescaping
- Change I needed to make in to_absolute_uri for unescaped URL separator characters
- how to replace a single backward slash with a double backward slash?