Grape entities and Single table inheritance
Asked Answered
T

0

7

Let's say i have Base class "Attachment < ActiveRecord::Base" and 2 child classes "Attachment::Video < Attachment" , "Attachment::Image < Attachment".

present Attachment.all, with: API::Entities::AttachmentEntity

But i want to use different entities for different subclasses. Attachment::Video should be present with API::Entities::AttachmentEntity::Video and so on

Is it possible in grape ?

Thirsty answered 10/10, 2016 at 9:36 Comment(2)
you have to loop and build the json manually.Citrin
if you are gonna represent different json structures, you batter expose those in different names. so that would make clients work easyCitrin

© 2022 - 2024 — McMap. All rights reserved.