我有一個簡單的問題,其中路由/ url名稱由用戶角色確定。目前顯示的路線是/new_admin/dispensaries
。如果用戶具有管理者或執行者的角色,那麼命名路線應該是'/ dashboards/dispensaries'。Rails中的動態命名路由
這是一種簡單,但難的是,在我的routes.rb:
命名空間:new_admin做 資源:vendor_templates 資源:markdown_docs 資源:email_lists
namespace :moderation do
resources :reported_reviews
end
resources :users do
member do
get :user_bans
post :ban_unban, to: 'user_bans#create'
delete :ban_unban, to: 'user_bans#destroy'
end
end
# TODO - this should be written generically to support dispensary/doctors/whatever
get '/dispensaries/reviews', :to => "reviews#all", :as => :all_reviews
get '/dispensaries/pictures', :to => "pictures#all", :as => :all_pictures
get '/dispensaries/videos', :to => "videos#all", :as => :all_videos
get "/dispensaries/autocomplete", to: "dispensaries#autocomplete"
resources :vendors do
resources :ownership_transfers, only: [:new, :create]
end
...
我因爲如果我更改new_admin路由,所以很多其他路由會受到影響。任何想法的傢伙?
我不太明白。爲什麼不爲儀表板創建新的命名空間,並將任何經理或主管人員重定向到新路徑? –
因爲我還是個新手,這就是爲什麼。讓我嘗試一下。 – Finks
對不起,如果聽起來居高臨下。解決方案對我來說有點顯而易見:) –