# How to retrieve group owners? (Rails code question)

**URL:** https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610
**Category:** Development
**Created:** [June 2, 2020, 7:17pm 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:** 4

<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: [June 4, 2020, 1:29am UTC](https://meta.discourse.org/t/how-to-retrieve-group-owners-rails-code-question/153610/4 "2020-06-04T01:29:21Z")

</div>

You’ll need to write a small plugin to serialize the correct information. I saw your #Marketplace post. Hopefully someone will take you up on that!

If you want to start seriously exploring plugins, you might consider checking out [Learn how to start building stuff for Discourse if you're newbie (like myself)](https://meta.discourse.org/t/how-to-start-building-stuff-for-discourse-if-youre-newbie-like-myself/45954)

I hacked something together as a super rough proof of concept that might give you a starting point to figure it out on your own:

**my-plugin/plugin.rb**

```ruby
# frozen_string_literal: true

# name: Group Test
# about: Group Test
# version: 0.1
# authors: Tester
# url: https://github.com/someone/something

enabled_site_setting :group_test_enabled

after_initialize do
  add_to_serializer(:basic_group, :owners) do
    GroupUser.where(group_id: object.id, owner: true).pluck("user_id")
  end
end

```

**my-plugin/config/settings.yml**

```yaml
plugins:
  group_test_enabled:
    default: false
    client: true

```

**In a theme’s `</head>` tab**

```handlebars
<script type="text/x-handlebars" data-template-name="components/groups-info">
 {{#if showFullName}}
   <span class="groups-info-name">{{group.full_name}}</span>
 {{else}}
   <span class="groups-info-name">{{group.displayName}}</span>
   {{#each group.owners as |owner|}}
      {{#if owner}}
        <div>{{owner}}</div>
      {{/if}}
   {{/each}}
 {{/if}}
</script>

```

If you put all of that together and enable the plugin in your site settings, you should see the user ids of the group owners listed on the groups page.

I won’t be able to help beyond that, so best of luck!

---

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