1
votes

I have an Ember.TextField bound to the title field in my Document model. I'm using the RESTAdapter and Ember 1.0.0-pre4.

Model and controllers

App.Document = DS.Model.extend({
  title: DS.attr('string')
});

App.DocumentController = Ember.ObjectController.extend({
});

App.ApplicationController = Ember.Controller.extend({
  save: function() {
    var doc = this.controllerFor('document'),
    model = doc.get('model');

    doc.store.commit();
  }
]);

document.handlebars template

{{view Ember.TextField valueBinding="title"}}

After calling the save method on my controller it will successfully save the title to the backend and will no longer be considered isDirty.

However if I input any data into the TextField after a save Ember Data throws me this error:

Uncaught Error: Attempted to handle event `willSetProperty`
on <App.Document:ember262:1> while in state rootState.error.
Called with
{reference: [object Object], store: <App.Store:ember268>, name: title}

What am I doing wrong?

1

1 Answers

2
votes

After some debugging it turns out that the PUT 204 success code returned by Rails is not enough for Ember to accept the changes made.

Here's what I did:

# format.json { head :no_content } # Rails default behavior
format.json { render json: @post } # Ember needs some data in return / 200 success code