简体   繁体   中英

Rails Devise Article from wiki throws error: undefined local variable or method `authenticated_user_root_path'

I wanted to add an admin and a user section into my rails 6 app, reading this tutorial https://github.com/heartcombo/devise/wiki/How-to-Setup-Multiple-Devise-User-Models#

I got the following error when is try to sign in as a user:

undefined local variable or method `authenticated_user_root_path' for #<Users::SessionsController:0x000000000824bbe0> Did you mean? authenticate_user!

This part can be found in part 6 of the wiki article.

What i am doing wrong here?

I think you should manually define 'authenticated_user_root' in your routes.rb

authenticated :user do
  root 'pages#index', as: :authenticated_user_root
end

You can also define another one for admin:

authenticated :admin do
  root 'admin_pages#index', as: :authenticated_admin_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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM