【发布时间】:2014-08-08 06:09:58
【问题描述】:
我收到以下错误 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
【问题讨论】:
-
为什么
100是硬编码的? -
执行
rake routes,您可以看到应用程序可用的路由模式。
标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 rspec