You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a JobSerializer that has 2 relationships - the hosted file, and outputs.
(This is because a job is rendered from a file that the user uploaded - the "hosted file" - and the result of running the job are output files - "outputs".)
Both the singular hosted file, and the plural output, relationships are modeled by a class called HostedFile (not backed by ActiveRecord, but rather backed by the filesystem).
I want to use the same serializer for both relationships, i.e. API::V1::HostedFileSerializer.
Is it possible to specify the serializer to use for a relationship, e.g.:
FWIW, I ended up defining Job#outputs to return an array of HostedFile instances, and this library seems to look at the type/class of the relationship... long story short, my JobSerializer#outputs relationship is correctly serialized using my HostedFileSerializer.
I have a
JobSerializer
that has 2 relationships - the hosted file, and outputs.(This is because a job is rendered from a file that the user uploaded - the "hosted file" - and the result of running the job are output files - "outputs".)
Both the singular hosted file, and the plural output, relationships are modeled by a class called
HostedFile
(not backed byActiveRecord
, but rather backed by the filesystem).I want to use the same serializer for both relationships, i.e.
API::V1::HostedFileSerializer
.Is it possible to specify the serializer to use for a relationship, e.g.:
Ideally I could then do something like the following and both relationships would be serialized using the
API::V1::HostedFileSerializer
:The text was updated successfully, but these errors were encountered: