What do you want to save?
Add Code snippet
New code examples in category Ruby
-
Mkinson 2021-09-04 01:26:02
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 Add solution
Best helpers
Mushi.f
+5
Ivan T.
+5
Bianco
+5
Graffito
+5
Mari Yoongi
+5
Tyr
+5
Christophrrb
+5
Vary
+5
Del Findley
+5
Ryan Friend
+5
Millemila
+5
Soumee
+5
Gftern
+5
Davesmiths
+5
Vocaro
+5
Vbence
+5