Log out of a specific user using Devise in Rails

I have Devise for user authentication. I want to display a user with a specific identifier.

in my controller

  def exit
    @user = User.find(5)
    sign_out(@user) # this line here signs out the current_user   
  end

Exit the development team, even if I pass @user, it writes out current_user. How can I select a user from a database and write it out using development teams?

+4
source share
2 answers

I assume that this is part of some administration module where you want to display a specific user.

. , , . , , .

: afaik sign_out , , , ( , ), , - . : - ( ), afaik . , :) sign_out , (afaik) .

, , - , : . , , , , .

( ), .

, activerecord, :

@session = ActiveRecord::Base.connection.select_all( "SELECT * FROM sessions WHERE session_id = '#{sess_id}'" )
Marshal.load(ActiveSupport::Base64.decode64(@session.data))

:

  • Timeoutable - ?
  • Rememberable, @user.forget_me, , ?
+5

Source: https://habr.com/ru/post/1545836/


All Articles