rails serializer has_many through code example
Example: how to display the has_many in the api serializer rails
class ProjectGroupSerializer < ActiveModel::Serializer
attributes :id, :name, :description, :projects
def projects
object.projects.map do |project|
::ProjectSerializer.new(project).attributes
end
end
end