开发者

Devise, remember_me and sign_in makes two separate updates to the DB?

开发者 https://www.devze.com 2023-03-29 19:05 出处:网络
In my app, a user has the ability to sign in as another user... It goes a little like this: desired_user.remember_me = true

In my app, a user has the ability to sign in as another user...

It goes a little like this:

desired_user.remember_me = true
sign_in(:user, desired_user.user)

Problem with this is it is hitting the DB twice with two expensive updates...

AREL (0.6ms)  UPDATE "users" SET "remember_created_a开发者_如何学编程t" = '2011-08-23 00:53:28.354913', "updated_at" = '2011-08-23 00:53:28.355860' WHERE "users"."id" = 3

AREL (0.8ms)  UPDATE "users" SET "last_sign_in_at" = '2011-08-23 00:52:16.255813', "current_sign_in_at" = '2011-08-23 00:53:28.391764', "sign_in_count" = 152, "updated_at" = '2011-08-23 00:53:28.393429' WHERE "users"."id" = 3
[paperclip] Saving attachments.

Is there a way to do this in one call. A way to sign_in and remember at the same time? I wasn't able to find this in the docs. Thanks

0

精彩评论

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