From d2a7aef6efc6ab54e44f673fc6506fcb6b821f7e Mon Sep 17 00:00:00 2001 From: Georgi Tapalilov Date: Mon, 27 Jan 2025 16:34:13 +0200 Subject: [PATCH] fix n+1 for categories (#1693) --- app/models/budget.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget.rb b/app/models/budget.rb index d59e9d41..9f6d6c07 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -94,7 +94,7 @@ class Budget < ApplicationRecord # Continuous gray segment for empty budgets return [ { color: "#F0F0F0", amount: 1, id: unused_segment_id } ] unless allocations_valid? - segments = budget_categories.map do |bc| + segments = budget_categories.includes(:category).map do |bc| { color: bc.category.color, amount: bc.actual_spending, id: bc.id } end