Answers for "rails serializer has_many"

0

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
Posted by: Guest on December-04-2020

Code answers related to "rails serializer has_many"

Browse Popular Code Answers by Language