本文介绍了我想覆盖设计 gem 的 authenticate_user 和 current_user 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想覆盖 authenticate_user!和我的应用程序控制器中设计 gem 的 current_user 方法,你能帮我解决这个问题吗谢谢
I want to override authenticate_user! and current_user method of devise gem in my application Controller can you please help me with regards to thatThanks
推荐答案
你可以像猴子补丁一样:
You may be able to monkey-patch it like:
module Devise
module Controllers
module Helpers
def authenticate_user!
#do some stuff
end
end
end
end
但我会问最终目标是什么,因为 Devise 已经内置了一些可定制性,而重写这些方法让我想知道为什么要使用 Devise?"
But I would ask what the ultimate goal is, because Devise has some customizability built into it already, and overriding these methods makes me wonder "why use Devise at all?"
这篇关于我想覆盖设计 gem 的 authenticate_user 和 current_user 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!