From 1abc42851a89aef0f7c1fd091de89f0033b8b4a6 Mon Sep 17 00:00:00 2001 From: Ari Timonen Date: Fri, 10 Apr 2020 19:58:36 +0300 Subject: [PATCH] Fix a bug when user was deleted --- app/controllers/application_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9ecb8c9..79418a1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -13,7 +13,12 @@ class ApplicationController < ActionController::Base respond_to :html, :js def cuser - @cuser ||= User.find(session[:user]) if session[:user] + begin + @cuser ||= User.find(session[:user]) + rescue + session[:user] = nil + @cuser = nil + end end def return_here