0
歌曲更簡單的方法有其在routes.rb
定義爲像/lyrics/The-notorious-b-i-g-ft-mase-and-puff-daddy/Mo-money-mo-problems
路徑:生成路徑上<a href="http://rapgenius.com" rel="nofollow noreferrer">Rap Genius</a>
map.song '/lyrics/:artist_slug/:title_slug', :controller => 'songs', :action => 'show'
當我要生成這樣的路徑,我使用song_url(:title_slug => song.title_slug, :artist_slug => song.artist_slug)
。不過,我更願意能夠輸入song_url(some_song)
。有沒有一種方法,我可以做到這一點,除了定義像一個幫手:
def x_song_path(song)
song_path(:title_slug => song.title_slug, :artist_slug => song.artist_slug)
end