![](/img/trans.png)
[英]ActionController::UrlGenerationError No Routes Matches for Nested Resource
[英]ActionController::UrlGenerationError: error No routes matches
我收到以下错误ActionController :: UrlGenerationError。
ActionController::UrlGenerationError:
No route matches {:action=>"/accounts/100", :controller=>"accounts"}
下面是抛出此错误的我的代码。
it "can find an account" do
Account.should_receive(:find, with: {id: 2055, authorization: @auth}
get "/accounts/100", nil, {"AUTH_TOKEN" => @auth}
hashed_response = {
"@type" => "test",
"createdAt" => "2014-07-24T15:26:49",
"description" => "Something about test",
"disabled" => false
}
expect(response.status).to eq 200
expect(response.body).to eq(hashed_response.to_json);
end
我做了一个谷歌,并知道没有为此定义的路线。 下面是我的config/routes.rb
文件
Rails.application.routes.draw do
resources :accounts do
resources :holders
end
end
我认为此错误来自控制器规范? 如果是这样,您只需使用表示您要调用的操作的符号,而不是URL本身。
例如。 这是一个表演动作,因此您可以使用:
get :show, id: 100
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.