# 为created\_by添加更多信息（来自user和user\_summary）

**URL:** <https://meta.discourse.org/t/adding-more-info-to-created-by-from-user-and-from-user-summary/183608>\
**Category:** Marketplace\
**Created:** [2021 年3 月 18 日 02:12 UTC](https://meta.discourse.org/t/adding-more-info-to-created-by-from-user-and-from-user-summary/183608 "2021-03-18T02:12:04Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![Mgcs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mgcs/32/202507_2.png) [@Mgcs](https://meta.discourse.org/u/Mgcs)\
发布日期： [2021 年3 月 18 日 02:12 UTC](https://meta.discourse.org/t/adding-more-info-to-created-by-from-user-and-from-user-summary/183608/1 "2021-03-18T02:12:04Z")

</div>

你好！

我想弄清楚如何在针对主题 ID 的 GET 请求中，向 `created_by` 添加更多信息。  
根据我的观察，它使用的是 `BasicUserSerializer`，返回的数据如下：

```
"created_by": {
  "id": 1,
  "username": "Name",
  "name": "Name",
  "avatar_template": "/user_avatar_url"
}

```

如果我想添加其他详细信息，例如 `likes_given`、`likes_received`、`created_at` 以及主题 OP 的其他相关信息，我该怎么做呢？

我查看了 `add_to_serializer`，并尝试了以下操作，但这会导致失败并使所有页面崩溃：

```
#customization:plugin.rb
after_initialize do
  add_to_serializer(:basic_user, :created_at) do
    object.created_at
  end
end

```

谢谢！

---

_[View the full topic](https://meta.discourse.org/t/adding-more-info-to-created-by-from-user-and-from-user-summary/183608)._
