压倒性的设计可恢复 [英] Overriding devise recoverable

查看:63
本文介绍了压倒性的设计可恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我的声誉低于50,所以我无法在这篇文章中接受的答案下方发表评论以获取更多信息。

As my reputation is lower than 50, so Im not able to comment below the accepted answer in this post In Rails Devise gem how to modify the send_reset_password_instructions method? for more information.

我想在设计中自定义 recoverable.rb 。我在路径为 lib / devise / models / recoverable.rb 的文件夹中制作了一个副本。问题是当请求发送重置密码指令时,出现错误未定义方法activerecord51? for Devise:Module 。我该如何解决?

I want to customize recoverable.rb in devise. I made a copy of it in my folder with path lib/devise/models/recoverable.rb. The problem is when request to send reset password instruction, I got error undefined method activerecord51? for Devise:Module. How do i solve this?

似乎我的可恢复不在Devise模块中。我通过在 lib / 文件夹中复制 devise.rb 进行了尝试。

It seems my recoverable is not in Devise module. I tried a bit by making a copy of devise.rb in lib/ folder. But it doesn't help.

有人可以帮忙吗?

编辑

给您带来的不便,我们深表歉意。目前,我只是想将更多选择传递给方法 send_reset_password_instructions

Sorry for any inconvenience. At the moment Im just trying to pass more opts to the method send_reset_password_instructions.

对此有任何想法吗?

Any idea about this?

推荐答案

在某些Rails初始化程序中如何?您可能正在覆盖原始的类/模块,因此所有其他方法都消失了。

How about do it in some rails initializer? Your are possibly overwriting the original class/module so all the other methods are gone.

# config/initalizers/devise.rb
Devise::Models::Recoverable::ClassMethods.module_eval do
  def send_reset_password_instructions(your, params)
    token = set_reset_password_token
    send_reset_password_instructions_notification(token)

    token
  end
end

这篇关于压倒性的设计可恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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