# 如何检索群组所有者？（Rails 代码问题）

**URL:** https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610
**Category:** Development
**Created:** [2020 年6 月 2 日 19:17 UTC](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610 "2020-06-02T19:17:29Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)
#### Post date: [2020 年6 月 4 日 02:14 UTC](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610/6 "2020-06-04T02:14:57Z")

</div>

> [@JQ331](#):
>
> 能否简要说明一下为什么这里需要序列化器？（我想理解的不仅是这个案例，还有其他自定义场景）

当然可以 🙂 默认情况下，数据并未通过 [BasicGroupSerializer](https://github.com/discourse/discourse/blob/master/app/serializers/basic_group_serializer.rb) 暴露出来。我们只包含必要的部分。

追踪起来有点像走迷宫，但 `groups-info` 组件之所以能拥有当前可用的数据，仅仅是因为它从父模板接收了 `group` 对象：

> <https://github.com/discourse/discourse/blob/d3c972c30cafb8ca595a60233a30f75b2f95336c/app/assets/javascripts/discourse/app/templates/groups/index.hbs#L53-L53>

而父模板的数据则来自控制器：

> <https://github.com/discourse/discourse/blob/d3c972c30cafb8ca595a60233a30f75b2f95336c/app/assets/javascripts/discourse/app/controllers/groups-index.js#L37-L37>

> [@JQ331](#):
>
> 我能否仅在我的仪表板中实现这一点？

恐怕不行。除非有什么我不知道的“魔法”！

---

_[View the full topic](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610)._
