This is my first question in Stackoverflow. :) My problem is the next:
I am trying to send a JSON to my API (via POST) with this format:
Events: [
{
id: 2,
name: "foo",
Eventcategories: [1,2]
}]
Embedding a hasMany Eventcategories association with EmbeddedRecordsMixin and this not appear in JSON serialized, only this:
Events: [
{
id: 2,
name: "foo"
}]
I have try this using ActiveModelSerializer and RESTSerializer without results.
GET response works without any problems.
I have an ember-cli project with these models:
--------event.js ----------------
var event = DS.Model.extend({
name: DS.attr('string'),
Eventcategories: DS.hasMany('eventcategory')
});
export default event;
---------eventcategoy.js ------------------
var eventcategory = DS.Model.extend({
tipo: DS.attr('string'),
Events: DS.hasMany('event')
});
export default eventcategory;
And this is my serializers:
-------event.js----------------------------
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin,{
attrs: {
Eventcategories: { embedded: 'always' }
}
});
------eventcategory.js --------------------
import DS from 'ember-data';
export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin,{
attrs: {
Events: { embedded: 'always' }
}
});
Could you help me?
Regards.
Angel