I am having a terrible time with this, but I have the following action on a controller:
saveOrganization: function() {
var org = this.get('model');
var users = org.get('users').then(function() {
console.log(org); //users are a part of org
org.save(); //users are not sent to server
});
}
and associated organization model:
export default DS.Model.extend({
createdAt: DS.attr('date'),
updatedAt: DS.attr('date'),
name: DS.attr('string'),
address: DS.attr('string'),
city: DS.attr('string'),
state: DS.attr('string'),
zip: DS.attr('string'),
users: DS.hasMany('user',{async:true}),
totalUsers: function() {
return this.get('users').get('length');
}.property('users.@each')
});
and associated users model:
export default DS.Model.extend({
createdAt: DS.attr('date'),
updatedAt: DS.attr('date'),
name: DS.attr('string'),
email: DS.attr('string'),
bio: DS.attr('string'),
picture: DS.attr('string'),
organization: DS.belongsTo('organization'),
type: DS.attr('string'),
username: DS.attr('string'),
password: DS.attr('string')
});
As you can see from the comments, when I get the users array as part of the organization, I can see the data, but when I save it, ember data never sends the users array as part of the data sent to the server.
Can anyone help me figure out what might be going on?
Thanks.