This is what happens when i try to save a model:
DEBUG: ------------------------------- ember.js:3521
DEBUG: Ember : 1.5.1 ember.js:3521
DEBUG: Ember Data : 1.0.0-beta.7+canary.b45e23ba ember.js:3521
DEBUG: Handlebars : 1.2.1 ember.js:3521
DEBUG: jQuery : 2.1.0 ember.js:3521
DEBUG: ------------------------------- ember.js:3521
Uncaught #<error> ember.js:73
The code that saves the model looks like this:(in a controller)
this.get('model').toArray().get('0').save();
Even if i save it like this it won't work:
this.get('model').save();
The model looks like this:
App.Imagepost = DS.Model.extend({
uploader: DS.attr(), // pojo {id:'1', name:'kfir', ...}
title: DS.attr('string'),
desc: DS.attr('string'),
tags: DS.attr(),// array ['#good', '#bad', '#fun', ...]
pics: DS.attr(), // array of objects
comments: DS.attr() // array of objects
});
I just try to save a fixture data model without even touching it.
Reading the model works fine my template renders perfectly but when i try to save i get this:
Uncaught #<error>
I tried to debug and seems like it breaks here:
if (content) { content.removeArrayObserver(this); }
line 25875 in Ember source, full context:
/**
Invoked when the content property is about to change. Notifies observers that the
entire array content will change.
@private
@method _contentWillChange
*/
_contentWillChange: Ember.beforeObserver('content', function() {
var content = this.get('content');
if (content) { content.removeArrayObserver(this); }
var len = content ? get(content, 'length') : 0;
this.arrayWillChange(content, 0, len);
}),
It is untouched JSON! why Ember-data can't save it?
Ember data is killing me spending 3 days just on workarounds and infinite bugs related to it
EDIT:
The comments are right the problem is that Ember-data doesnt save arrays which breaks my template with this error.
Where can i find the code which Ember data uses to save stuff? I want to modify it so arrays will be saved
Shall i forfeit and acknolwedge that Ember data is an untamed beast and drop my mongo backend in favor of mysql so Ember data will be happy once again
this.get('model').save(). But you havent included enough context to know what the problem might be. Are you creating a new model and saving it or are you updating a model? If using ember data what server/database are you using? Your model seems a bit off too. Dont think you should be using arrays in there. Instead each one should be a separate model, ie tags is a model, pics is a model, and then they have a relationship to your model. emberjs.com/guides/models/defining-models/… - Craicerjack