app/controllers/api/v1/groups_controller.rb
class Api::V1::GroupsController < Api::V1::BaseController
expose :group, -> { Group.find(params[:id]) }
api :GET, '/api/v1/groups/ID', "Returns group with id ID."
param :id, :number, "Group id of the requested group"
def show
authorize! :read, group
render json: group.as_json(methods: [:title, :avatar_url, :profile_fields]).merge({
important_officers: group.important_officers.collect do |hash|
{
description: hash[:description],
user: hash[:user].as_json(methods: [:title, :avatar_url, :profile_fields])
}
end
})
end
end