vendredi 13 novembre 2015

How to send HABTM as JSON in Rails API

I am currently working on a recipe app that uses Ember on the frontend and a Rails API on the back. In Rails I have a has and belongs to many relationship between recipes and ingredients. My ingredients model not only stores the ingredient name, but nutritional information so I am not able to simple store ingredients as an array field on recipes.

I am currently confused about how I should set up my Rails API to send properly formatted JSON. According to this

website

Ember expects JSON to be formatted something like this: enter image description here

Assuming this is correct, how should I achieve this in my Rails API?




Aucun commentaire:

Enregistrer un commentaire