diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index f684b27f3..0c61e2b69 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -87,7 +87,10 @@ class MessagesController < ApplicationController end def show - @message = Message.includes(:attachments, :message_detail, :children, :author => :user_extension, :board => [{course: :board_course_modules}]).find_by_id params[:id] + @message = Message.includes(:attachments, :message_detail, + :children, :author => :user_extension, + :board => [{course: :board_course_modules}]) + .find_by_id params[:id] return normal_status(-2, "ID为#{params[:id]}的帖子不存在") if @message.nil? @attachment_size = @message.attachments.size diff --git a/app/models/message.rb b/app/models/message.rb index 6b41cdd95..7588ddc2a 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -73,7 +73,7 @@ class Message < ApplicationRecord # 包含二级回复的总点赞数 def total_praises_count - descendants.sum(:praises_count) + praises_count + descendants.sum(:praises_count) end # 包含二级回复数的总回复数