未定义的局部变量或方法`sign_out_path' [英] undefined local variable or method `sign_out_path'

查看:38
本文介绍了未定义的局部变量或方法`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?

推荐答案

可能有两个原因:

  1. 您没有在路由配置文件中定义正确的路由
  2. 您为现有路线使用了路径助手,但错误地使用了错误的名称

先行耙道.查看输出,看看是否可以看到以"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_out_path'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆