繁体   English   中英

更新到Rails 5和Devise 4.0.0.rc1后,设计authenticate_user! 方法没有定义

[英]After updating to Rails 5 and Devise 4.0.0.rc1, the devise authenticate_user! method is not defined

我有一个rails应用程序,它与设计3和轨道4完美运行。我将rails更新为5并且它给了DEPRECATION WARNING: alias_method_chain is deprecated 所以我不得不将设计版本更改为4.0.0.rc1。

现在似乎设计没有生成像authenticate_user!这样的方法authenticate_user! is_admin等..

我收到以下错误

Before process_action callback :authenticate_user! has not been defined (ArgumentError)

我尝试了一切,包括卸载设计并再次安装,然后尝试从头开始创建一个单独的模型,但仍未定义方法。

有什么想法吗?

答案是简单地改变:

skip_before_action :authenticate_user!

至 - -

skip_before_action :authenticate_user!, raise: false

https://github.com/plataformatec/devise/issues/4207 https://github.com/thoughtbot/clearance/issues/621

我可以确定问题,在rails 5中,如果在调用时未定义跳过方法,则会有异常,除非我们添加:unless条件。

在rails5支持自己设计之前,你可以尝试使用这个fork:

gem 'devise', github: 'twalpole/devise', branch: 'rails5'

暂无
暂无

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

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