我再次與軌道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