我正在使用link_to嘗試刪除記錄,但我收到一條錯誤,指出刪除路徑不存在。當查看html表單中的href時,href的形式是:id/controller而不是controller /:id。我有兩個這樣的例子,一個用於Edit,似乎按預期工作,另一個用於Remove,路由似乎關閉。我看到的主要區別是locale沒有在destroy href中定義。任何想法是什麼導致這個問題?我之前以不同的形式看到了這一點,但我開始更頻繁地看到這一點。任何幫助將非常感激。HTML創建href的軌道路線錯誤順序
路線:
topdressings GET (/:locale)/topdressings(.:format) topdressings#index {:locale=>/en|es/}
POST (/:locale)/topdressings(.:format) topdressings#create {:locale=>/en|es/}
new_topdressing GET (/:locale)/topdressings/new(.:format) topdressings#new {:locale=>/en|es/}
edit_topdressing GET (/:locale)/topdressings/:id/edit(.:format) topdressings#edit {:locale=>/en|es/}
GET (/:locale)/topdressings/:id(.:format) topdressings#show {:locale=>/en|es/}
PATCH (/:locale)/topdressings/:id(.:format) topdressings#update {:locale=>/en|es/}
PUT (/:locale)/topdressings/:id(.:format) topdressings#update {:locale=>/en|es/}
DELETE (/:locale)/topdressings/:id(.:format) topdressings#destroy {:locale=>/en|es/}
HTML:
<td><%= link_to t(:edit), edit_topdressing_path(topdressing), data: { toggle: "modal", target: "#EditModal_#{topdressing.id}", remote: edit_topdressing_path(topdressing) + "#modal-edit-form" }, remote: true %>
|
<%= link_to t(:remove), topdressings_path(topdressing), method: :delete, data: { confirm: t(:confirm_remove_topdressing, device: "#{topdressing.topdressing_device.name}", date: "#{topdressing.date}") } %></td>
HREF詳細信息頁來源
<td><a data-toggle="modal" data-target="#EditModal_1" data-remote="/en/topdressings/1/edit#modal-edit-form" data-remote="true" href="/en/topdressings/1/edit">Edit</a>
|
<a data-confirm="Are you sure you want to delete the record for Device 2 on 2016-02-26" rel="nofollow" data-method="delete" href="/1/topdressings"><span>Remove</span></a></td>
ERROR ON DELETE:
Started DELETE "/1/topdressing" for 127.0.0.1 at 2016-03-05 14:34:06 -0800
ActionController::RoutingError (No route matches [DELETE] "/1/topdressing"):
web-console (2.0.0.beta3) lib/action_dispatch/debug_exceptions.rb:22:in `middleware_call'
點
HTML形式的詳情: