在设计模型确认后进行自定义操作 [英] Do custom action after devise model confirmation
本文介绍了在设计模型确认后进行自定义操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道,一旦用户在设计中确认了Confirmable
帐户,就可以使用以下方式更改重定向网址:
I know once the user has confirmed a Confirmable
account in devise, I can change the redirect URL with:
def after_confirmation_path_for(resource)
view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
end
但是,如果我想在确认后在resource
上调用自定义方法,我该如何用devise做到这一点?我想我可以用这种方法坚持下去...
But if I wanted to call a custom method on the resource
after confirmation, how would I do that with devise? I suppose I could stick it in this method...
def after_confirmation_path_for(resource)
resource.do_thing_after_confirmation
view_context.admin_dashboard_url_for(subdomain: resource.tenant.subdomain)
end
但是使用这种方法更改模型并不恰当.
But that doesn't feel right to have this method changing the model.
推荐答案
I found a blank method in Devise::Models::Confirmable
that is called during the confirm!
method. I'm going to override this method in my User resource model and do my work here.
def after_confirmation
end
这篇关于在设计模型确认后进行自定义操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文