diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 065aa0978..3f34454fa 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -21,17 +21,19 @@ class PostsController < ApplicationController def show @post = Post.find(params[:id]) - @comments = @post.comments - @comments = @comments.includes(:creator) - @comments = @comments.includes(:votes) if CurrentUser.is_member? - @comments = @comments.visible(CurrentUser.user) + if request.format == Mime::Type.lookup("text/html") + @comments = @post.comments + @comments = @comments.includes(:creator) + @comments = @comments.includes(:votes) if CurrentUser.is_member? + @comments = @comments.visible(CurrentUser.user) - include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children? - @sibling_posts = @post.parent.present? ? @post.parent.children : Post.none - @sibling_posts = @sibling_posts.undeleted unless include_deleted + include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children? + @sibling_posts = @post.parent.present? ? @post.parent.children : Post.none + @sibling_posts = @sibling_posts.undeleted unless include_deleted - @child_posts = @post.children - @child_posts = @child_posts.undeleted unless include_deleted + @child_posts = @post.children + @child_posts = @child_posts.undeleted unless include_deleted + end respond_with(@post) do |format| format.html.tooltip { render layout: false }