How to retrieve group owners? (Rails code question)

I’m not totally clear on what you are trying to achieve, but I think you are looking for GroupUser. You can get a list of group_ids and their owners’ user_ids using something like:

GroupUser.where(owner: true).pluck("group_id", "user_id")