From cf653740bacee97d228868632481a792a5585aa3 Mon Sep 17 00:00:00 2001
From: p31729568 <winse.wang@foxmail.com>
Date: Tue, 16 Jul 2019 14:36:07 +0800
Subject: [PATCH] fix

---
 app/controllers/accounts_controller.rb                |  1 -
 app/controllers/attachments_controller.rb             |  1 -
 app/controllers/concerns/controller_rescue_handler.rb |  4 ++++
 app/controllers/concerns/error_common.rb              | 10 ----------
 app/models/searchable/shixun.rb                       |  4 ++--
 5 files changed, 6 insertions(+), 14 deletions(-)
 delete mode 100644 app/controllers/concerns/error_common.rb

diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 3020588e0..7159c2bca 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -1,6 +1,5 @@
 class AccountsController < ApplicationController
 
-  include ErrorCommon
   #skip_before_action :check_account, :only => [:logout]
 
   def index
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index c539b0a60..5132e203c 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -5,7 +5,6 @@ class AttachmentsController < ApplicationController
   before_action :require_login, :check_auth
   before_action :find_file, only: %i[show destroy]
 
-  include ErrorCommon
   include ApplicationHelper
 
   def show
diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb
index 31934db03..71e2e9178 100644
--- a/app/controllers/concerns/controller_rescue_handler.rb
+++ b/app/controllers/concerns/controller_rescue_handler.rb
@@ -15,5 +15,9 @@ module ControllerRescueHandler
     rescue_from ActiveRecord::RecordInvalid do |ex|
       render_error(ex.record.errors.full_messages.join(','))
     end
+    rescue_from Exception do |e|
+      logger.error e
+      render json: {status: -1, message: e.message}
+    end
   end
 end
\ No newline at end of file
diff --git a/app/controllers/concerns/error_common.rb b/app/controllers/concerns/error_common.rb
deleted file mode 100644
index 5a5f41673..000000000
--- a/app/controllers/concerns/error_common.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-module ErrorCommon
-  extend ActiveSupport::Concern
-
-  included do
-    rescue_from Exception do |e|
-      logger.error e
-      render json: {status: -1, message: e.message}
-    end
-  end
-end
\ No newline at end of file
diff --git a/app/models/searchable/shixun.rb b/app/models/searchable/shixun.rb
index e4108024c..7abd76ec6 100644
--- a/app/models/searchable/shixun.rb
+++ b/app/models/searchable/shixun.rb
@@ -21,8 +21,8 @@ module Searchable::Shixun
 
   def searchable_user_data
     {
-      author_name: user.real_name,
-      author_school_name: user.school_name,
+      author_name: user&.real_name,
+      author_school_name: user&.school_name,
     }
   end