mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 00:00:46 +08:00
DEV: Use has_many and ArraySerializer for SidebarSectionsSerializer (#26716)
This commit is contained in:

committed by
GitHub

parent
10f77556cd
commit
a6b8051645
@ -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
|
||||
|
Reference in New Issue
Block a user