From 6311a80724cb781b1a252c07e8123f590d932350 Mon Sep 17 00:00:00 2001 From: Daniel Waterworth Date: Fri, 9 Feb 2024 11:48:26 -0600 Subject: [PATCH] FIX: Preload associations on subcategories when lazy loading categories (#25630) --- app/models/category_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/category_list.rb b/app/models/category_list.rb index 7ae4704f388..83698d89872 100644 --- a/app/models/category_list.rb +++ b/app/models/category_list.rb @@ -159,7 +159,7 @@ class CategoryList .where(parent_category_id: @categories.map { |c| c.id }) @categories += - Category.where( + Category.includes(CategoryList.included_associations).where( "id IN (WITH cte AS (#{categories_with_rownum.to_sql}) SELECT id FROM cte WHERE rownum <= ?)", SUBCATEGORIES_PER_CATEGORY, )