I am trying to route root to devise sign in path under a subdomain
constraint.
My config/routes.rb
look something like this
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
I am getting the error Could not find devise mapping for path "/".
Any suggestions as to how I route to root path in a subdomain with devise scope?
Thanks
To add an authentication constrain to a route use the devise authenticated
method:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.