class DashboardsController < ApplicationController
  before_action :authenticate_user!

  def show
    @posts = Post.all
  end
end

class DashboardsController < ApplicationController
  before_action :authenticate_user!

  def show
    @posts = Post.all.includes(:user)
  end
end

Use ActiveRecord's includes finder to avoid N+1 problem
Use ActiveRecord's includes finder to avoid N+1 problem
