实训评论回复问题

dev_forum
daiao 5 years ago
parent 7082358c7c
commit 67b6b735cd

@ -39,6 +39,12 @@ class Discuss < ApplicationRecord
shixun.has_manager?(user) ? content : ''
end
def child_discuss(user)
user.admin? ?
Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) :
Discuss.where(parent_id: self.id, :hidden => false).includes(:user).reorder(created_at: :asc)
end
private
def send_tiding

@ -2,7 +2,7 @@ json.author do
json.partial! 'users/user', user: discuss.user
end
json.id discuss.id
json.content discuss.contents(container, current_user)
json.content discuss.contents
json.time time_from_now(discuss.created_at)
json.position discuss.position
json.shixun_id discuss.dis_id

@ -2,8 +2,7 @@ json.disscuss_count @disscuss_count
json.all @current_user.admin?
json.comments @discusses do |discuss|
json.partial! 'discusses/discuss', locals: { discuss: discuss, container: @container, current_user: @current_user }
child_discuss = Discuss.children(discuss.id)
json.children child_discuss do |c_d|
json.children discuss.child_discuss(current_user) do |c_d|
json.partial! 'discusses/discuss', locals: { discuss: c_d, container: @container, current_user: @current_user }
end
end

Loading…
Cancel
Save