[英]ActionController::RoutingError (No route matches {:action=>“show”, :controller=>“users”, :id=>nil}):
[英]ActionController::RoutingError: No route matches {:controller=>“vendors”, :action=>“vendors”}?
在測試中,我正在嘗試致電
get :vendors
但是我得到的錯誤是
ActionController::RoutingError: No route matches {:controller=>"vendors",
:action=>"vendors"}
我在routes.rb中確實有以下內容
match '/vendors', :to => 'vendors#index'
所以我不明白為什么它要尋找(不存在的)“供應商”行動,而不是像匹配的那樣使用“索引”。 有人可以向我解釋嗎?
因為你告訴過嗎?
該測試已經進行describe VendorsController
,大概是在describe VendorsController
進行了describe VendorsController
,因此說get :vendors
告訴它獲得Vendors#vendors動作。 並不是說“獲取/ vendors URL”,而是直接進入控制器。
通常,您運行get :action
而不是get :controller
或get :matched_route_name
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.