我遇到问题的两条特定路线是管理/检查和管理/活动。当我第一次保存routes.rb时,无论我首先加载哪条路线都工作但另一条路线不工作,它会给我一个错误:" Unitialized constant Admin :: Towers"
我有以下路线设置。
namespace :admin do
#...etc...
resources :inspections, only: [:index,:show], controller: 'towers/inspections'
resources :activities, only: [:index], controller: 'towers/activities'
end
答案 0 :(得分:1)
当您为资源命名空间时,您的控制器应位于app/controllers/admin/*
内并具有名称,即用于检查:class Admin::InspectionsController
我猜你想要:
scope '/admin' do
resources :inspections, only: [:index,:show], controller: 'towers/inspections'
resources :activities, only: [:index], controller: 'towers/activities'
end