[英]How to execute some function after login or logout in Devise?
I need to get a historial of users when login and logout from application. 从应用程序登录和注销时,我需要获取用户的历史记录。 I use
devise
for model user
in Frontend (I have a model adminUser
for ActiveAdmin
/ Devise
login in Backend) 我使用
devise
的model user
在前端(我有一个model adminUser
为ActiveAdmin
/ Devise
在后端登录)
How can I execute function where I save that information in other table? 我如何执行将信息保存到其他表中的功能?
Current routes.rb: 当前的route.rb:
Rails.application.routes.draw do
devise_for :users
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
In devise I override the default controllers while using super to invoke a method of the same name in the parent, after that's run you can then execute whatever you want. 在设计中,我在使用super调用父级中同名的方法时覆盖了默认控制器,运行完后,您可以执行所需的任何操作。
For example: 例如:
class Users::SessionsController < Devise::SessionsController
# POST /resource/sign_in
def create
super
# >> Do some stuff
end
# DELETE /resource/sign_out
def destroy
super
# >> Do some different stuff
end
end
I'm not 100% sure that's what you mean, but I hope it's helpful 我不确定100%就是您的意思,但希望对您有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.