PERF: N+1 query on badges index.

This commit is contained in:
Guo Xiang Tan 2016-04-12 17:45:02 +08:00
parent ad1d14ecbe
commit 983d64fd56
1 changed files with 1 additions and 0 deletions

View File

@ -5,6 +5,7 @@ class Admin::BadgesController < Admin::AdminController
badge_types: BadgeType.all.order(:id).to_a,
badge_groupings: BadgeGrouping.all.order(:position).to_a,
badges: Badge.includes(:badge_grouping)
.includes(:badge_type)
.references(:badge_grouping)
.order('badge_groupings.position, badge_type_id, badges.name').to_a,
protected_system_fields: Badge.protected_system_fields,