Uncaught Error: Assertion Failed: Cannot delegate set


#1

i face this error when saving data to api

Uncaught Error: Assertion Failed: Cannot delegate set(‘firstName’, a) to the ‘content’ property of object proxy <>: its ‘content’ is undefined

below is my code

import Ember from 'ember';


export default Ember.ObjectController.extend({
    isValid: Ember.computed(
        'email',
        'firstName',
        'lastName',
        'twitter',
        function() {
            return !Ember.isEmpty(this.get('email')) &&
            !Ember.isEmpty(this.get('firstName')) &&
            !Ember.isEmpty(this.get('lastName')) &&
            !Ember.isEmpty(this.get('twitter'));
        }
        ),
    actions:{
        save: function() {
            if (this.get('isValid')) {
                var _this = this;
                this.get('model').save().then(function(friend) {
                    _this.transitionToRoute('friends.show', friend);
                });
            } else {
                this.set('errorMessage', 'You have to fill all the fields');
            }
        },
        cancel: function() {
            this.transitionToRoute('friends');
        }
        
    }
    
});

#2

You haven’t declared any firstName variable in your controller.

So that, if you haven’t assigned a model (in your route) that has that variable there is no object where the setter can actually set the value of firstNamevariable.