I know that Ember-Data should be compatible with Serializers Active Model by design, but they don't seem to be able to serialize has_many relationships with inline identifiers.
For example, serializer
class PostSerializer < ActiveModel::Serializer embed :ids has_many :comments end
creates json
{ "post": { "comment_ids": [...] } }
But the default configuration in Ember Data,
App.Post = DS.Model.extend({ DS.hasMany('App.Comment'), }); App.Comment = DS.Model.extend();
expects that the association of comments will be serialized as comments: [...] without the _ids suffix (see the relationship section of the Ember.js REST adapter section ).
I tried the following:
class PostSerializer < ActiveModel::Serializer attribute :comments def comments object.comment_ids end end
This works, but adding embed :ids, :include => true to enable lateral loading now does nothing, because AMS does not know that this is an association.
Edit: I am using active_model_serializers (0.6.0) gem and version of Ember-Data 11
source share