[英]Rails route inconsistency and ActionController::RoutingError - No route matches
我出現了這個錯誤,我做了很多搜索,但似乎找不到正確的解決方案。 它在一個視圖中工作,而在另一個視圖上引發錯誤。
ActionController::RoutingError - No route matches {:action=>"status", :controller=>"orders", :status=>"canceled"}:
錯誤是從下一行拋出的
app / views / orders / _chef-states.html.erb- 部分
<%= link_to status_order_path(status: r.first.id2name),
data: { confirm: 'Are you sure?' },
method: :put,
remote: true do %>
<i class="icon-ok icon-white"></i>
<span><strong><%= r.first.id2name.capitalize %></strong></span>
<% end %>
上面的partial用於兩個地方:
在位置一(即show.html.erb)中,它工作正常,但在位置二,則引發路由錯誤。
routes.rb
resources :orders do
member do
put 'status'
get 'print'
end
get 'chef' , on: :collection
end
有人可以建議可能是什么問題或我可以如何解決。
完整的日志轉儲可以在pastebin上找到
我實際上發現了問題,在第二個視圖(chef.html.erb)中,我沒有傳遞訂單對象,因為狀態是訂單控制器上的成員路由。
令人困惑?
<%= render 'orders/chef-states', order: order %>
我錯過了
order: order
在第二種視圖中,它因此引發了錯誤,在這種情況下,錯誤消息某種程度上不是很容易解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.