Hi everyone,
I am developping a small emberjs application. I have 2 models, one represents people, the second one represents trips.
import DS from 'ember-data';
var attr = DS.attr;
export default DS.Model.extend({
firstname: attr("string"),
lastname: attr("string"),
trips: DS.hasMany('trip')
})
and
import DS from 'ember-data';
var attr = DS.attr;
export default DS.Model.extend({
date: attr("string"),
location: attr("string"),
});
I have a “new” view to create a new person. In this view, have a button with an action “addTrip”.
addTrip: function(date, location, reason) {
var trip = this.store.createRecord("trip", {
date: date,
location: location,
});
trip.save();
this.get('trips').pushObject(trip);
}
But this is throws me an error. I read this topic: createRecord that has hasMany relationship
Is it possible to add relationships to a being created model, here, for example, the person model?
Thanks for your help.
Michael