我有一個在Rails中創建的在線組合,其中包含不同的項目。我希望能夠通過關鍵字過濾項目。我的方法是爲ProjectsController中的每個關鍵字定義一個方法,並鏈接關鍵字以調用方法。在Controller中調整方法調用的routes.rb
對於實例關鍵字= graphic_design:
<%= link_to 'Graphic Design', :action => "filter_"[email protected]_s %>
這樣,我得到的錯誤:
Couldn't find Project with ID=filter_graphic_design
這是我相當明顯。我的問題:有沒有辦法告訴routes.rb行爲只有'filter_'方法不同?還有其他建議嗎?