posts: eager load uploader and media asset on posts show page.
Eliminate a couple SQL queries by loading the uploader and media asset in the same query as the post.
This commit is contained in:
@@ -27,7 +27,7 @@ class PostsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@post = authorize Post.find(params[:id])
|
@post = authorize Post.eager_load(:uploader, :media_asset).find(params[:id])
|
||||||
|
|
||||||
if request.format.html?
|
if request.format.html?
|
||||||
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
include_deleted = @post.is_deleted? || (@post.parent_id.present? && @post.parent.is_deleted?) || CurrentUser.user.show_deleted_children?
|
||||||
|
|||||||
Reference in New Issue
Block a user