From 5c4eca47a6f7f016b57a548ec646c8edfece72b8 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 23 Dec 2015 17:01:23 -0500 Subject: [PATCH] Fix some more n+1 stuff --- app/controllers/subcreddits_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/subcreddits_controller.rb b/app/controllers/subcreddits_controller.rb index 083abea..2332315 100644 --- a/app/controllers/subcreddits_controller.rb +++ b/app/controllers/subcreddits_controller.rb @@ -10,7 +10,7 @@ class SubcredditsController < ApplicationController end def show - @posts = @subcreddit.posts + @posts = @subcreddit.posts.includes(:user) authorize @subcreddit end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 2c57b82..047dd59 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,7 +2,7 @@ class UsersController < ApplicationController def show @user = User.friendly.find(params[:id]) - @comments = @user.comments.includes(:post) + @comments = @user.comments.includes(post: :subcreddit) end def new