1
我的模型数据正在正确序列化和反序列化,但最终会对已存在的数据提出额外请求,并在JSON文档中进行侧装。 (这些请求失败,因为我们没有对这些对象的端点)ember-data为belongsTo关系创建额外的GET请求
例如:
GET http://localhost:3000/api/2/apps/53fde960cc095d0e0000002d/in_app_message_buttons/5405c098cc095d88e800000b 404 (Not Found)
我使用Rails和烬数据。在铁轨边,我的串行看起来是这样的:
class PopUpMessageVariationSerializer < ActiveModel::Serializer
embed :ids, include: true #model not properly deserialized till we added this
has_one :cta_button, :root => :in_app_message_button
has_one :cancel_button, :root => :in_app_message_button
has_one :headline, :root => :message_labels
has_one :body, :root => :message_labels
end
我烬的数据模型是这样的:
PopUpMessageVariation = InAppMessageVariation.extend(Ember.Validations.Mixin, {
ctaButton: DS.belongsTo('in_app_message_button'),
cancelButton: DS.belongsTo('in_app_message_button'),
headline: DS.belongsTo('message_label'),
body: DS.belongsTo('message_label'),
});
而烬串行:
PopUpMessageVariationSerializer = DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
headline: { embedded: 'always' },
body: { embedded: 'always' },
ctaButton: { embedded: 'always' },
cancelButton: { embedded: 'always' }
}
});
我尝试添加{异步:假}的关系,但它没有效果。