I have done some research and seen that this question has already been addressed several times, in different places:
I tried to follow the examples given in the links above and came up with the following solution, in my routes.rb
file:
root to: 'pages#home'
devise_for :users, :path => 'account', controllers: { registrations: "registrations", confirmations: "confirmations" }
authenticated :user do
root 'calendars#index', as: :authenticated_root
end
The goal here is to direct unauthenticated
users to the regular home
page of the website, while authenticated
users will go to their dashboard, inside the app, ie the calendars#index
route, defined as follows in my routes:
calendars GET /calendars(.:format) calendars#index
However, when I log in as a user, and visit http://localhost:3000/
, I keep landing on the regular home
page of the website, instead of the user's dashboard inside the app.
What am I doing wrong?
Change routes.rb
so that the unauthenticated root
route is wrapped, just like the authenticated one:
devise_for :users, :path => 'account', controllers: { registrations: "registrations", confirmations: "confirmations" }
authenticated :user do
root 'calendars#index', as: :authenticated_root
end
unauthenticated :user do
root 'pages#home', as: :unauthenticated_root
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.