Skip to content

Commit

Permalink
FIX: Preload associations on subcategories when lazy loading categori…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwaterworth authored Feb 9, 2024
1 parent 250ce25 commit 6311a80
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/category_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def find_categories
.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,
)
Expand Down

0 comments on commit 6311a80

Please sign in to comment.