Skip to content

A platform for community discussion. Free, open, simple.

PERF: no need to select entire group just to find name

Sam Saffron5a8451bf892f
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 22c24fafb32..0f9c896da70 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -125,7 +125,9 @@ module ApplicationHelper
result << "category-#{@category.url.sub(/^\/c\//, '').gsub(/\//, '-')}"
end
- if current_user.present? && primary_group_name = current_user.primary_group&.name
+ if current_user.present? &&
+ current_user.primary_group_id &&
+ primary_group_name = Group.where(id: current_user.primary_group_id).pluck(:name).first
result << "primary-group-#{primary_group_name.downcase}"
end