我的投票鏈接通常工作,除非鏈接通過ajax部分呈現。當通過JavaScript部分渲染時,我得到一個路由錯誤,在螢火蟲中可見並且沒有錯誤。僅當使用ajax時導軌路由錯誤
沒有螢火蟲我知道有一個錯誤,因爲當我嘗試添加一個新的製造商時沒有添加製造商。如果我手動刷新頁面,則鏈接和新制造商出席並投票。
所以基本上使用ajax打破投票鏈接。
耙路線:
vote_car_manufacturer POST /cars/:car_id/manufacturers/:id/vote(.:format) manufacturers#vote
觀點:
<%= link_to '+', vote_car_manufacturer _path(car_id: @car.id, manufacturer_id: manufacturer.id, type: "up"), method: "post" %>
螢火蟲:
No route matches {:action=>"vote", :controller=>"manufacturers", :car_id=>1, :manufacturer_id=>29, :type=>"up"}
使用Ajax時我一定要執行不同的投票鏈接?
UPDATE
得到通過試驗和錯誤時半的工作。更改:
<%= link_to '+', vote_car_manufacturer _path(car_id: @car.id, manufacturer_id: manufacturer.id, type: "up"), method: "post" %>
到:
<%= link_to '+', vote_car_manufacturer _path(@car.id, manufacturer.id, "up"), :method => :post %>
現在它說,沒有一個ID,所以我還在調試中無法找到生產廠家。
AJAX調用呈現的部分(包括鏈接)。鏈接本身不是ajax鏈接。 – 2013-02-24 23:51:58