Error saving model without Ember.DS


#1

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 ``.


#2

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

http://www.ember-cli.com/#upgrading-an-ember-cli-app


#3

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.


#4

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.


#5
model.gallery = tempGallery;

should be

model.set('gallery', tempGallery)