From 1113a02715777cfb2ce1e2d4eadfbcdf7ee081af Mon Sep 17 00:00:00 2001 From: Georgi Tapalilov Date: Sat, 25 Jan 2025 22:02:08 +0200 Subject: [PATCH] fix n+1 for categories --- 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 2abfe2cf..6a5efb25 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 -- 2.53.0