How to create and save a model with a belongsTo relationship in Ember-Data


I’m getting the next error when I’m trying to save a new record with an associated relationship. The problem I think is related to the creation of the record because ember doesn’t create any record.

Uncaught TypeError: Cannot call method 'save' of undefined

On the one hand, my models are the following (with a one-to-many relationship).

App.Kid = DS.Model.extend({
    attribute1: DS.attr("string"),
    parent: DS.belongsTo(parent)

App.Parent = DS.Model.extend({
    attribute1: DS.attr("string"),
    kids: DS.hasMany(kid)

On the other hand, my route is the following.

App.KidRoute = Ember.Route.extend({
    model: function (id) {
        var store = this.get('store');
        store.find('usuario', id).then(function(parentmodel){
            return'kid', {parent: parentmodel});
        save: function(){

Any help would be appreciate. Thanks!


It is necessary to set the mapping on the adapter through embedded: 'always'? Any thoughts?


hey there, just a suggestion, people here usually does not reply to this type of questions, it would be better to ask in . This forum is mostly used for ideas, suggestions, and to discuss new features.


I’d already posted there but I thought this forum would be more helpful for ember questions. Thanks for the clarification!


@alopez, can you please share the Stack Overflow link for this question? I was wondering about this same thing. Did you figure out how to do it? How to save the id for a related record.