I’m looking to hook into devise after login / after session create. How would I go about doing this?
Basically I want to set a users location every time they login, and to do that I need an after login hook of sorts.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Devise updates the value of the
user.current_sign_in_attimestamp on successful login. So, you could simply add abefore_savefilter to your User model. In that filter, check to see if the value of this field has changed, and if it has, set the users location.BTW – I’m not sure what you mean by “location” – if you mean IP address, Devise already stores that for you.