...

/

Retrieve User’s Products

Retrieve User’s Products

Learn how to Incorporate relationships to display the corresponding products in the JSON output of a user.

In the previous lesson, we learned how to include user information in the JSON of the products. We can do the same by including product information related to a user for the /api/v1/users/1 page.

Add relationships to the serializer

Like the belongs_to attribute for the product, we need to add the relationship has_many in our user_serializer.rb. ...