From 3dd6234a0a11db7dbb63e1325efb02031d13f8de Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 23 Dec 2019 14:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index e8fee2ed1..652ffea37 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -54,9 +54,14 @@ class Discuss < ApplicationRecord def send_tiding base_attrs = { trigger_user_id: user_id, parent_container_id: challenge_id, parent_container_type: 'Challenge', - belong_container_id: dis_id, belong_container_type: 'Shixun', viewed: 0, tiding_type: 'Comment' + belong_container_id: dis_id, belong_container_type: dis_type, viewed: 0, tiding_type: 'Comment' } - user_id = has_parent? ? parent.user_id : Challenge.find(challenge_id).user_id + user_id = + if dis_type == 'Shixun' + has_parent? ? parent.user_id : Challenge.find(challenge_id).user_id + elsif dis_type == 'Hack' + has_parent? ? parent.user_id : Hack.find(dis_id).user_id + end tidings.create!(base_attrs.merge(user_id: user_id)) end end