Error saving model without Ember.DS

I have an Ember project that I had been working on where I could save my model in my route:

        Ember.$.ajax({
        url: config.api.baseURL + 'propzone/' + model.name,
        type: 'PUT',
        contentType: 'application/json',
        data: JSON.stringify(model),
        success: function() {
            // RENDER NOTIFICATION
            self.refresh();
        },
        error: function(err) {
            alert('Error: ' + err);
        }
    });

This did work fine until I updated Ember and Ember-cli.

Now I’m getting this error message:

Uncaught Error: Assertion Failed: You must use Ember.set() to set the gallery property (of [object Object]) to ``.

Have you taken all the steps mentioned in the upgrade section?

What I did was: update ember and update ember-cli.

Once those were finished I created a new project. I didn’t actually use the old project. I just copied code that I needed into my new project.

I ‘was’ modifying the model in my route like so:

save: function() {
			var self = this;
			var model = this.currentModel;

			// Remove inactive images
			var l = model.gallery.length;
			var tempGallery = [];

			while (l--) {
				var g = model.gallery[l];

				// Change back to http...
				g.src.small = g.src.small.replace(config.https.baseURL, config.cdn.baseURL);
				g.src.medium = g.src.medium.replace(config.https.baseURL, config.cdn.baseURL);
				g.src.large = g.src.large.replace(config.https.baseURL, config.cdn.baseURL);

				if (g.active === true) {
					tempGallery.push(g);
				}
			}
			model.gallery = tempGallery;

… … .

I take it this is not the proper Ember way? I’m using Ember-cli and I do not have any models declared in the models directory. In my route, I have a json call where I read in my model.

model.gallery = tempGallery;

should be

model.set('gallery', tempGallery)
1 Like