diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-29 16:44:47 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-29 16:44:47 +0100 |
commit | 75fb68c4d1eb647a268890c080da2dc3875c0e77 (patch) | |
tree | c3e20c251a4d065475e8f6d685a14b669a09bbe4 /app/controllers/application_controller.rb | |
parent | a9be92fdc62d55e6b6a8da80f0fe959ad90fa678 (diff) |
Get rid of @current_user. The use of current_user is better.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e4165f3..2d49890 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -106,7 +106,7 @@ class ApplicationController < ActionController::Base end rescue_from CanCan::AccessDenied do |exception| - if @current_user + if current_user redirect_to root_url, :alert => 'Access denied! Please ask your admin to grant you the necessary rights.' else if Tenant.count == 0 && User.count == 0 @@ -121,13 +121,13 @@ class ApplicationController < ActionController::Base private - def current_user - begin - @current_user ||= User.find(session[:user_id]) if session[:user_id] - rescue ActiveRecord::RecordNotFound + def current_user + if session[:user_id] && User.where(:id => session[:user_id]).any? + return User.where(:id => session[:user_id]).first + else session[:user_id] = nil + return nil end - @current_user end def go_to_setup_if_new_installation |