我有一个客户设计控制器,我想设置我的注册操作,当用户在用户注销时登录和离线时,将用户状态更新为在线。我有
def signin
super
end
我希望在注销时将用户状态属性更新为登录和离线状态。请在这里提供帮助
答案 0 :(得分:0)
您可能缺少用户表“status”属性的attr_accesible声明吗?
答案 1 :(得分:-2)
您可以使用设计中提供的after_sign_in_path_for和after_sign_out_path_for挂钩。只需在ApplicationController中覆盖这些方法即可。例如
class ApplicationController < ActionController::Base
private
def after_sign_in_path_for(resource_or_scope)
#update user status to online
root_path
end
def after_sign_out_path_for(resource_or_scope)
#update user status to offline
root_path
end
end
此处有更多信息:devise wiki