如何在命名空间中指定模块?
How to specify module in namespace?
我想做类似的事情:
namespace :dashboard do
get 'speed'
get 'engine'
get 'oil'
get 'errors', :to => 'warn_system#errors', :module => false
end
只有错误 link 到另一个控制器。
dashboard_speed GET /dashboard/speed(.:format) dashboard#speed
dashboard_oil GET /dashboard/oil(.:format) dashboard#oil
dashboard_engine GET /dashboard/engine(.:format) dashboard#engine
dashboard_errors GET /dashboard/errors(.:format) dashboard/warn_system#errors {:module=>false}
最后一条记录,我希望它是
dashboard_errors GET /dashboard/errors(.:format) warn_system#errors
我该怎么办?
如果重要的话,我正在使用 Rails 3。
要路由到命名空间内的不同控制器,请指定控制器的绝对路径。如果 warn_system 控制器在根命名空间中,使用:
namespace :dashboard do
get 'errors', :to => '/warn_system#errors'
end
更新:
根据您的评论,您似乎想使用:
namespace :dashboard do
get 'errors', :to => '/dashboard/warn_system#errors'
end
对于 Rails 3,试试这个:
scope '/dashboard' do
get 'errors', :to => 'warn_system#errors'
end
我想做类似的事情:
namespace :dashboard do
get 'speed'
get 'engine'
get 'oil'
get 'errors', :to => 'warn_system#errors', :module => false
end
只有错误 link 到另一个控制器。
dashboard_speed GET /dashboard/speed(.:format) dashboard#speed
dashboard_oil GET /dashboard/oil(.:format) dashboard#oil
dashboard_engine GET /dashboard/engine(.:format) dashboard#engine
dashboard_errors GET /dashboard/errors(.:format) dashboard/warn_system#errors {:module=>false}
最后一条记录,我希望它是
dashboard_errors GET /dashboard/errors(.:format) warn_system#errors
我该怎么办? 如果重要的话,我正在使用 Rails 3。
要路由到命名空间内的不同控制器,请指定控制器的绝对路径。如果 warn_system 控制器在根命名空间中,使用:
namespace :dashboard do
get 'errors', :to => '/warn_system#errors'
end
更新:
根据您的评论,您似乎想使用:
namespace :dashboard do
get 'errors', :to => '/dashboard/warn_system#errors'
end
对于 Rails 3,试试这个:
scope '/dashboard' do
get 'errors', :to => 'warn_system#errors'
end