mercredi 12 octobre 2016

Ember Data Polymorphic Relationship: Not Using Correct Model

Using an older version of ember(1.7.1) and ember-data(1.0.0 beta 12) as trying to upgrade to 2.0. When loading my application I get the following warning:

WARNING: The payload for 'App.QPAC' contains these unknown keys: [abs_parent_gbid,author,comments,course,follows,has_more_comments,is_announcement,more_comments_count,resource_uri,title]. Make sure they've been defined in your model.

Here is my model code (There are other models than post but they aren't being loaded in this instance).

App.Feedstory = DS.Model.extend({
    global_id: DS.attr('string'),
    story_type: DS.attr('string'),
    story: DS.belongsTo('qPAC', {polymorphic: true}),
});

App.QPACBasic = DS.Model.extend({
    isLikedByMe: function(){
        return this.get("my_vote") === 1;
    }.property('my_vote'),
    replyCount: function() {
        var count = 0;
        this.get('comments').forEach(function(comment){
            count++;
        });
        return count;
    }.property('comments.@each')
});

App.QPAC = App.QPACBasic.extend({
    global_id: DS.attr('string'),
    global_code: DS.attr('string'),
    body: DS.attr('string'),
});

App.Post = App.QPAC.extend({
    title: DS.attr('string'),
    is_announcement: DS.attr('boolean'),
    author: DS.belongsTo('user'),
    comments: DS.hasMany('comment'),
});

Server Response

Ember inspector is showing me that the all the feedstory objects of type Post are being found and it shows in the Post attributes that the correct IDs are being loaded but not the other attributes.

The warning says it's looking for the post attributes in the App.QPAC model and not App.Post. Any ideas?




Aucun commentaire:

Enregistrer un commentaire