Serialize Associations

Serialize the users' and products' associations.

As we’ve seen in the previous lessons, working with serializers is fairly simple. In some cases, the most difficult decision is naming the routes or structuring the JSON output. When working with associations between models on an API, however, there are many approaches we can take.

Luckily, we don’t have to worry about this problem in our case. The JSON:API specifications did it for us!

To summarize, we have a has_many type association between users and products.

Get hands-on with 1200+ tech skills courses.