我再次与轨道3和路线摔跤。正常化参数轨道中的命名路线
这里的问题是:
我创造了这样一个例子具名的路线:
match '/download/artist/:artist/album/:albumName', :to => "albums#show", :as => :search, :via => :get
这给了我这条路线:search_path
我也有经典的一个是这样的: get "albums/show"
,给了我这条路线:albums_show_path
。
然而,当我使用SEARCH_PATH像这样的一些参数:
<%= link_to "#{result.name[0..50]}(...)", search_path(:artist =>result, :albumName => result.name), :class => "albumName" %>
,它失败了,但不是与albums_show_path。以下是错误:
no route matches {:controller=>"albums", :action=>"show", :artist=>"Eddie Vedder & Ben Harper", :albumName=>"My City of Ruins/My Father's House (Live) [Benefiting Artists for Peace and Justice Haiti Relief] {Digital 45}"}
我知道这可能是因为ALBUMNAME参数没有逃脱。但即使尝试用CGI.escape
逃脱它,也不起作用。我想我必须在route.rb中完成它,但我不知道如何。
你有什么想法如何做到这一点?
编辑
错误说:没有路由匹配等 当我没有非法字符的参数,它找到的路线。
**编辑rake routes
**
welcome_index GET /welcome/index(.:format) {:controller=>"welcome", :action=>"index"} albums_index GET /albums/index(.:format) {:controller=>"albums", :action=>"index"} albums_show GET /albums/show(.:format) {:controller=>"albums", :action=>"show"} search GET /download/artist/:artist/album/:albumName(.:format) {:controller=>"albums", :action=>"show"} albums_show_album_info GET /albums/show_album_info(.:format) {:controller=>"albums", :action=>"show_album_info"} albums_show_itunes GET /albums/show_itunes(.:format) {:controller=>"albums", :action=>"show_itunes"} albums_show_spotify GET /albums/show_spotify(.:format) {:controller=>"albums", :action=>"show_spotify"} albums_show_carrefour GET /albums/show_carrefour(.:format) {:controller=>"albums", :action=>"show_carrefour"} root /(.:format) {:controller=>"welcome", :action=>"index"}
什么是错误?我没有看到一个,真的吗? – Ariejan 2010-12-21 13:25:00
我加了一些细节。但基本上,错误是没有路线匹配。但是它找到没有'('的路线 – Pasta 2010-12-21 13:35:39