When you delete the account that you are currently signed in as, you remove the User from the database, however the session[:user_id] is still set to the now deleted User's ID.

Attempting to call User#find with a user ID which has been deleted will result in an ActiveRecord error.

The reason why this does not happen when the ||= operator is present is because the @current variable is already set therefore the User#find is never called.

# this will only try to call User#find if the @current variable is not already set
@current ||= User.find(session[:user_id])
# this will always attempt to call User#find
# if session[:user_id] is set to a deleted user's ID it will raise an error
@current = User.find(session[:user_id])