我正在尝试将root路由到subdomain
约束下的路径设计。
我的config/routes.rb
看起来像这样
Rails.application.routes.draw
constraints subdomain: 'admin' do
devise_scope :admin do
root to: 'devise/sessions#new'
# here I override devise routes
end
end
root to: 'pages#homepage'
# rest of the routes
end
我收到错误Could not find devise mapping for path "/".
关于如何在具有设计范围的子域中路由到根路径的任何建议?
由于
答案 0 :(得分:1)
要向路由添加身份验证约束,请使用设计authenticated
方法:
Rails.application.routes.draw
constraints subdomain: 'admin' do
authenticated :admin do
# the root page for authenticated users
root 'admin#dashboard', as: :authenticated_root
end
root to: 'devise/sessions#new'
end
# this is for no subdomain
root to: 'pages#homepage'
end