I'm using devise for the first time in a project so probably this is gonna be a newbie question, I would like to know how to make a user rememberable after si开发者_Go百科gnup. Currently I'm logging in the user after signup with something like this:
class UsersController < Devise::RegistrationsController
respond_to :html, :json, :js
def create
if request.format.js? || request.format.json?
build_resource
resource.save
sign_in :user, resource if resource.valid? && request.format.js?
respond_with resource
else
super
end
end
end
Note I have my own version of create since I need to respond to javascript and json requests. Any help would be appreciated.
Thanks in advance!.
I haven't actually tried this yet but you should be able to call resource.remember_me!
and that should take care of creating the token and saving it for the given resource.
精彩评论