简体   繁体   English

Rails Devise 来自 wiki 的文章抛出错误:未定义的局部变量或方法 `authenticated_user_root_path'

[英]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#我想在我的 rails 6 应用程序中添加一个管理员和用户部分,阅读本教程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.这部分可以在 wiki 文章的第 6 部分中找到。

What i am doing wrong here?我在这里做错了什么?

I think you should manually define 'authenticated_user_root' in your routes.rb我认为您应该在您的 routes.rb 中手动定义“authenticated_user_root”

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Rails和Devise的未定义局部变量或方法 - Undefined local variable or method with Rails & Devise 设计不使用滑轨。 (Gemfile的未定义局部变量或方法“ devise”) - Devise not working with rails. (Undefined local variable or method `‘devise’' for Gemfile) undefined局部变量或方法`root_path&#39; - undefined local variable or method `root_path' Rails错误-未定义的局部变量或方法`signout_path&#39; - Rails Error - undefined local variable or method `signout_path' Rails Devise将经过身份验证的用户重定向到特定路径 - Rails Devise redirecting authenticated user to a specific path 编辑其他用户设计ruby on rails错误未定义的局部变量或方法resource_name - Edit other users devise ruby on rails error undefined local variable or method resource_name 为什么我不能在User实例方法中使用root_path?(未定义的局部变量或方法) - Why I can't use root_path in User instance method?(undefined local variable or method) 未定义的局部变量或方法自动完成路径4 - undefined local variable or method autocomplete path rails 4 Rails Devise STI-未定义的局部变量或方法“用户” <QuizSession> - Rails Devise STI - undefined local variable or method `users' for <QuizSession> 在 Rails 引擎中使用设计的未定义方法“user_session_path” - undefined method `user_session_path' using devise in rails engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM