Answers for "has_many through serializer rails"

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 "has_many through serializer rails"

Browse Popular Code Answers by Language