我在下面有这样的路线。如果我有这样的路线有可能吗?
#config/routes
resources :subscribers, only: [:index, :show]
namespace :admin do
resources :subscribers, only: [:new, :edit, :update, :create, :destroy]
end
我试图运行rake 路线,结果是
admin_subscribers POST /admin/subscribers(.:format) admin/subscribers#create
new_admin_subscriber GET /admin/subscribers/new(.:format) admin/subscribers#new
edit_admin_subscriber GET /admin/subscribers/:id/edit(.:format) admin/subscribers#edit
admin_subscriber PUT /admin/subscribers/:id(.:format) admin/subscribers#update
DELETE /admin/subscribers/:id(.:format) admin/subscribers#destroy
subscribers GET /subscribers(.:format) subscribers#index
subscriber GET /subscribers/:id(.:format) subscribers#show
结果符合我的期望,但是当我运行我的 RSpec 时出现错误
Routing Error
uninitialized constant Admin::SubscribersController
Try running rake routes for more information on available routes.
我也在我的 Rspec Helper 中添加了以下代码
#spec/spec_helper.rb
Spork.each_run do
###
if /spork/i =~ $0 || RSpec.configuration.drb?
ActiveSupport::Dependencies.clear
end
###
end
但是,如果我将浏览器启动到 htt**://l*alhost:3000/admin/subscribers/new,一切都很好。我错过了什么吗?