Answers for "rails serializers has many through"

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 serializers has many through"

Browse Popular Code Answers by Language