【发布时间】:2015-09-21 22:43:26
【问题描述】:
我在其他相关问题中找不到解决方案,所以我问自己的问题。
问题很简单。这是我得到的错误:
Failure/Error: get 'api/v2/special_keys#show'
ActionController::UrlGenerationError:
No route matches {:action=>"api/v2/special_keys#show", :controller=>"api/v2/special_keys"}
这是我的routes.rb:
resources :special_keys, only: [] do
collection do
get '', to: 'special_keys#show'
end
end
这是rake routes的输出:
GET /api/v2/special_keys(.:format) api/v2/special_keys#show {:format=>"json"}
还有我的规格:
require 'rails_helper'
describe Api::V2::SpecialKeysController do
describe 'GET #show' do
it 'gets the policy and signature' do
get '/api/v2/special_keys'
expect(response.status).to eql 200
end
end
end
【问题讨论】:
-
你的控制器代码是什么样的?难道你只允许json格式?
-
是的,我确实只允许 json 格式。
-
在下面试试我的答案。
标签: ruby-on-rails rspec