开发者

Devise rememberable on signup

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜