DEV: Use has_many and ArraySerializer for SidebarSectionsSerializer (#26716)

This commit is contained in:
Daniel Waterworth
2024-05-06 11:32:18 -05:00
committed by GitHub
parent 10f77556cd
commit a6b8051645
7 changed files with 32 additions and 23 deletions

View File

@ -11,7 +11,14 @@ class SidebarSectionsController < ApplicationController
.includes(:sidebar_urls)
.where("public OR user_id = ?", current_user.id)
.order("(public IS TRUE) DESC, title ASC")
.map { |section| SidebarSectionSerializer.new(section, root: false) }
sections =
ActiveModel::ArraySerializer.new(
sections,
each_serializer: SidebarSectionSerializer,
scope: guardian,
root: "sidebar_sections",
)
render json: sections
end