In Devise, I'm signing in my user like this:
sign_in_and_redirect(:user, user)
In the default sign in page, there's a checkbox that the user can select so that they don't have to sign in again when they return to the site. But when you do the sign in with the sign_in_and_redirect(:user, user)
line, I can't work out how to set that parameter to yes. Does anyone know how? Thanks for reading.
current_user.remember_me!
https://github.com/plataformatec/devise/blob/master/lib/devise/models/rememberable.rb#L54
Note that this only updates the remember_created_at
value of the user record. But for this to work correctly, a validation token also needs to be stored in the Devise cookie. To achieve both these things, follow Dmytrii's advise and user the remember_me <USER>
controller method instead:
include Devise::Controllers::Rememberable
...
remember_me <USER_OBJECT>