[英]ActionController::RoutingError: No route matches {:controller=>“vendors”, :action=>“vendors”}?
In my test, I'm trying to call 在测试中,我正在尝试致电
get :vendors
but the error I get is 但是我得到的错误是
ActionController::RoutingError: No route matches {:controller=>"vendors",
:action=>"vendors"}
I do have the following in routes.rb 我在routes.rb中确实有以下内容
match '/vendors', :to => 'vendors#index'
so I don't get why it's looking for the (non-existent) "vendors" action instead of using "index" like it's matched. 所以我不明白为什么它要寻找(不存在的)“供应商”行动,而不是像匹配的那样使用“索引”。 Can anyone explain this to me?
有人可以向我解释吗?
Because you told it to? 因为你告诉过吗?
The test is already contextualized, presumably with describe VendorsController
, so saying get :vendors
tells it to get the Vendors#vendors action. 该测试已经进行
describe VendorsController
,大概是在describe VendorsController
进行了describe VendorsController
,因此说get :vendors
告诉它获得Vendors#vendors动作。 It isn't saying "get the /vendors URL", it's going straight to the controller. 并不是说“获取/ vendors URL”,而是直接进入控制器。
In general, you run get :action
not get :controller
nor get :matched_route_name
通常,您运行
get :action
而不是get :controller
或get :matched_route_name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.