I am using devise in a Rails 3 app.
I would like to update some attributes of a User on a successful sign in.
I am doing it the following way:
I added following code to application_controller.rb
def after_sign_in_path_for(user)
@user = current_user
@user.status = "online"
@user.save
root_path
end
Is it possible to have a different method for doing this and not using the method that is used for defining the after_sign_in_path ?
Thanks in advance!
You can do this with hooks to warden.
##config/initializers/devise.rb
Warden::Manager.after_authentication do |user,auth,opts|
user.update_attribute(:currently_signed_in, true)
end
Warden::Manager.before_logout do |user,auth,opts|
user.update_attribute(:currently_signed_in, false)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With