app/helpers/sessions_helper.rb
def current_user
    if (user_id = session[:user_id])
      @current_user ||= User.find_by(id: user_id)
    elsif (user_id = cookies.signed[:user_id])
      user = User.find_by(id: user_id)
      if user&.authenticated?(cookies[:remember_token])
        sign_in user
        current_user = user
      end
    end
  end
# Returns the user corresponding to the remember token cookie.
Returns the user corresponding to the remember token cookie.
Returns the user corresponding to the remember token cookie .
def current_user
    if (user_id = session[:user_id])
      @current_user ||= User.find_by(id: user_id)
    elsif (user_id = cookies.signed[:user_id])
      user = User.find_by(id: user_id)
      if user&.authenticated?(cookies[:remember_token])
        sign_in user
        current_user = user
      end
    end
  end
def current_user if ( user_id = session [ :user_id ] ) @current_user ||= User . find_by ( id : user_id ) elsif ( user_id = cookies . signed [ :user_id ] ) user = User . find_by ( id : user_id ) if user &. authenticated? ( cookies [ :remember_token ] ) sign_in user current_user = user end end end
Returns the user corresponding to the remember token cookie.
Returns the user corresponding to the remember token cookie .