When you first start using Ember-Data its pretty nifty to see your application making JSON requests to create/read/update your entities but at some point you might want to cut down on the number of requests that your Ember app is making to the server. One technique for doing this is to sideload your associations.
So if you’ve got a User entity which has many opinons, you can include the opinions in the /users/<id> response, instead of simply returning the user with ids for the opinions which would cause your application to create new requests for each of the opinions.
First you need to configure your RESTAdapter to expect these opinions in sideloaded form:
Your Ember-data User model should look like:
Now, if you have a Rails back-end and you’re using the Active Model Serializers gem, you can simply modify the UserSerializer to include the Opinions in the User response.
assuming that you have a User Model with a has_many association to the Opinion model.