Don't do unnecessary processing on posts when using the API

This commit is contained in:
BrokenEagle
2020-02-12 23:55:02 +00:00
parent f7495f5e26
commit 75f4af8991

View File

@@ -21,6 +21,7 @@ class PostsController < ApplicationController
def show def show
@post = Post.find(params[:id]) @post = Post.find(params[:id])
if request.format == Mime::Type.lookup("text/html")
@comments = @post.comments @comments = @post.comments
@comments = @comments.includes(:creator) @comments = @comments.includes(:creator)
@comments = @comments.includes(:votes) if CurrentUser.is_member? @comments = @comments.includes(:votes) if CurrentUser.is_member?
@@ -32,6 +33,7 @@ class PostsController < ApplicationController
@child_posts = @post.children @child_posts = @post.children
@child_posts = @child_posts.undeleted unless include_deleted @child_posts = @child_posts.undeleted unless include_deleted
end
respond_with(@post) do |format| respond_with(@post) do |format|
format.html.tooltip { render layout: false } format.html.tooltip { render layout: false }