Skip to content

Commit

Permalink
Merge pull request #504 from sau226dev/sau226/fix-question-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- authored May 30, 2021
2 parents 33bf9d2 + 176100b commit 31efd74
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def delete
if @post.update(deleted: true, deleted_at: DateTime.now, deleted_by: current_user,
last_activity: DateTime.now, last_activity_by: current_user)
PostHistory.post_deleted(@post, current_user)
if @post.children.any?
@post.children.update_all(deleted: true, deleted_at: DateTime.now, deleted_by_id: current_user.id,
if @post.children.where(deleted: false).any?
@post.children.where(deleted: false).update_all(deleted: true, deleted_at: DateTime.now, deleted_by_id: current_user.id,
last_activity: DateTime.now, last_activity_by_id: current_user.id)
histories = @post.children.map do |c|
{ post_history_type: PostHistoryType.find_by(name: 'post_deleted'), user: current_user, post: c,
Expand Down

0 comments on commit 31efd74

Please sign in to comment.