From 7d91c0349a2b5325044f9ef9a9f6ad7534217411 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 2 Feb 2023 00:44:42 +0100 Subject: [PATCH] Eagerly load services in action to prevent n+1 query --- app/controllers/inbox_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index c38f2c49..a31080e8 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -18,7 +18,7 @@ class InboxController < ApplicationController @delete_id = find_delete_id @disabled = true if @inbox.empty? - services = current_user.services + services = current_user.services.to_a respond_to do |format| format.html { render "show", locals: { services: } }