未定义的局部变量或方法`sign

编程入门 行业动态 更新时间:2024-10-11 05:23:24
本文介绍了未定义的局部变量或方法`sign_out_path'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Rails应用的初学者.我已将devise gem用于身份验证目的.当我登录其显示错误时:未定义的局部变量或方法'sign_out_path'

I'm beginner in rails application. I have used devise gem to authentication purpose. when I log in its showing error: undefined local variable or method `sign_out_path'

我该如何解决这个问题?

How can I solve this problem?

推荐答案

可能有两个原因:

  • 您没有在路由配置文件中定义正确的路由
  • 您为现有路线使用了路径助手,但错误地使用了错误的名称
  • 先行耙道.查看输出,看看是否可以看到以"devise"开头的任何路由.

    First run rake routes. Have a look through the output and see if you can see any routes beginning with "devise".

    如果可以看到一个名为"destroy_user_session"的名称,那么实际上这是您需要用于注销链接的名称,而不是"sign_out_path".在这种情况下,请转到放置退出链接的视图,然后用"destroy_user_session_path"替换帮助程序.

    If you can see one called "destroy_user_session" then this is actually the name you need to use for your sign out link, and not "sign_out_path". In that case, go to the view where you have put your sign out link and replace the helper with "destroy_user_session_path".

    更多推荐

    未定义的局部变量或方法`sign

    本文发布于:2023-10-27 23:44:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1534879.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:变量   局部   未定义   方法   sign

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!