Hello,
I’m having this error om my model : Uncaught TypeError: Cannot read property 'pushObject' of undefined
So I have two models with Relations like this :
var ApplicationPasswords = DS.Model.extend({
userId: DS.belongsTo('user', {async: true}),
passwordName: DS.attr('string'),
username: DS.attr('string'),
password: DS.attr('string'),
system: DS.attr('boolean'),
});
and
var User = DS.Model.extend({
firstname: DS.attr('string'),
lastname: DS.attr('string'),
login: DS.attr('string'),
passwordGen: DS.attr('string'),
groups: DS.hasMany('group', {async: true}),
rights: DS.hasMany('right', {async: false}),
serializedRights: DS.attr(),
language: DS.attr('string'),
source: DS.belongsTo('ldap', {async: true}),
applicationPasswords: DS.hasMany('application-passwords', {async: true}),
isInternal: Ember.computed.equal('source.id', '0'),
In the controller on the model user
, I’m trying to insert a applicationPasswords
like that :
createApplicationPasswords: function(partner) {
const currentUser = this.currentUser;
console.log(currentUser.model);
console.log(currentUser.model.id);
const newAp = this.store.createRecord('application-passwords', {
userId: currentUser.model.id,
passwordName: 'partner_id=' + partner.id,
username: this.get('newUsername'),
password: this.get('newPassword'),
system: false,
});
newAp.save();
currentUser.get('applicationPasswords ').pushObject(newAp);
currentUser.save();
},
but I’m having undefined on currentUser.get('applicationPasswords ').pushObject(newAp);
I don’t really know why, my model is declared, I have no route on applications-password
model because I’m using in inside the controller of user
model.
Ember 1.13