Cannot set read-only property for hasMany association


#1

Hi there,

I have a serializer video.js

export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
    attrs: {
        videoScenes:  { embedded: 'always' },
        videoColours: { embedded: 'always' }
    }
});

which works great when I call model.save() on my video models.

However I have a route start.js that has;

model: function() {
    var store = this.store;
    return Ember.$.getJSON("/start").then(function(data) {
        return store.createRecord("video", data.video);
    });
}

that throws Uncaught Error: Cannot set read-only property "videoScenes" on object: <frontend@model:video::ember885:12262> my guess is that the start route is not using the video serializer?

Are serializers tied to models or routes? How can I get this route to deserialize the json as it does under video routes?


#2

Thanks to user locks in Slack I needed to use store.pushPayload(data); then I can do a `store.getById(“video”, data.video.id);