2012-02-17 103 views
4

所以我有一個簡單的模型歌曲標題和喜歡作爲屬性。Link_to軌道導致路由錯誤

我在歌曲索引頁上以表格形式顯示它。我想通過點擊鏈接來增加喜歡的數量。

我有這個在我看來目前:

<td> <%= link_to 'LIKE', :action => "update", :remote => true%> </td> 
我songs_controller.rb

我有:

def update 
    @song = Song.find(params[:id])                                 
    @song.likes +=1 

我得到點擊鏈接此錯誤:

No route matches [GET] "/assets" 

我知道這是基本的,請有人幫我理解這裏發生了什麼?

謝謝

UPDATE !!!!!!!我把這個按照我的config.assets.enabled application.rb中 =假

但是我還是這樣的:

No route matches {:action=>"update", :remote=>true, :controller=>"songs"} 

回答

4

包裝你:action參數,以確保路由器實現:remote說法是不屬於你的路徑:

<%= link_to 'LIKE', {:action => "update"}, :remote => true %>