FIX 处理点赞数异常的问题

dev_forum
jasder 5 years ago
parent 9f9f3a85f2
commit 37737fe786

@ -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

@ -73,7 +73,7 @@ class Message < ApplicationRecord
# 包含二级回复的总点赞数
def total_praises_count
descendants.sum(:praises_count)
praises_count + descendants.sum(:praises_count)
end
# 包含二级回复数的总回复数

Loading…
Cancel
Save