我在想如果以下路由文件中的路由結構可以接受。我還沒有看到過這樣做的例子,但它看起來合乎邏輯。如果不是,請讓我知道爲什麼。Ruby On Rails和Routes文件結構
Rails.application.routes.draw do
### BEGIN /some_base_route/
namespace :some_base_route do
### BEGIN /some_base_route/lead_vendor
namespace :lead_vendor do
get 'import'
get 'results'
end
### END /some_base_route/lead_vendor
### BEGIN /some_base_route/sales/
namespace :sales do
get 'view_lead'
get 'edit_lead'
post 'edit_lead'
get 'create_contact_log'
get 'login'
get 'dashboard'
end
### END /some_base_route/sales/
### BEGIN /some_base_route/admin/
namespace :admin do
get 'admin/login'
get 'admin/dashboard'
end
### END /some_base_route/admin/
### BEGIN /some_base_route/process/
namespace :process do
### BEGIN /some_base_route/process/sales
namespace :sales do
### BEGIN /some_base_route/process/sales/leads
namespace :leads do
get 'create'
get 'edit'
get 'delete'
get 'call_log_create'
end
### END /some_base_route/process/sales/leads
end
### END /some_base_route/process/sales
### BEGIN /some_base_route/process/new_client
namespace :new_client do
get 'new_client/step1'
get 'new_client/step2'
get 'new_client/step3'
get 'new_client/step4'
get 'new_client/step5'
get 'new_client/step6'
end
### END /some_base_route/process/new_client
### BEGIN /some_base_route/process/admin/
namespace :admin do
### BEGIN /some_base_route/process/admin/user_management/
namespace :user_management do
get 'create'
get 'edit'
get 'delete'
get 'disable'
end
### END /some_base_route/process/admin/user_management/
### BEGIN /some_base_route/process/admin/services/
namespace :services do
get 'create'
get 'edit'
get 'delete'
end
### END /some_base_route/process/admin/services/
end
### END /some_base_route/process/admin/
end
### END /some_base_route/process/
end
### END /some_base_route/
您可以運行'rake routes'來自己檢查路線。 –
@ArieShaw我在問,如果這是一個接受的路線結構,以我的方式嵌套它們。 Rake的工作沒有問題!我只是想知道這是否違反任何ROR編程範式。 –
結構對我來說看起來不錯,嵌套結構允許在Rails中使用'namespace',但是除非絕對需要,否則不應該使用深層嵌套 –