Is it possible to embed and include related objects using ActiveModel :: Serializer?

We are in a weird situation where we have a limb-supported point that includes data and lateral loads. I have no idea why it was built this way, and why no one thought hey, we seem to be sending all of this data twice

, but explaining the reasons why the former stewards of our code is the task of Sisyphus.

I am rewriting the JSON output currently by hand to use serializers because removing useless code is good news. However, I cannot imagine two questions:

1) There seems to be no way to embed an object as well as load it. I know I can disconnect by setting embed :ids, include: true

, but this only returns ids

side-loaded objects from the parent relation.

2) Is there a way not to set a status embeds

for each relationship? It seems like the only way to set something sideways or inline is with a string embed :ids...

, but that affects everything that is a relation. How can I get more granular control over attachment / upload?

+3
ruby-on-rails serialization activemodel active-model-serializers


source to share


No one has answered this question yet

Check out similar questions:

305
What is Object Serialization?
226
Serializing an Object to a String
46
How to pass parameters to ActiveModel serializer
1
Serialize only one object with ActiveModel :: Serializer
1
ActiveModel Versions :: Serializer
1
Include current_user in ActiveModel :: Serializer
0
Include Nested Association IDs in ActiveModel Serializers
0
how to define association in ActiveModel :: Serializer
0
ActiveModel Serializer for Complex Associations
0
Data transformation



All Articles
Loading...
X
Show
Funny
Dev
Pics