Save (post) & update (put) ember-data infinite loop when upgrading to ember 1.0.0-4 and ember-data 1.0.0.beta.3


#1

I trying to upgrade a small github Todo sample project (with java on server side) using TodoMVC ember sample on client side (upgrade based this topic)

The previous version with emberJs RC8 and ember-Data V013 is fully working fine. On server side, I have only modified todo’s attribute from underscored (is_completed) to camelized (isCompleted)

Currently, when receiving the server response, ember seems to not understand it and resend an post/put command, again and again… What I am doing wrong ??

todo.js:

Todos.Todo = DS.Model.extend({ 
    title: DS.attr('string'),
    isCompleted: DS.attr('boolean'),
        
    saveWhenCompletedChanged: function () { 		
        this.save();
    }.observes('isCompleted')
});

app.js:

window.Todos = Ember.Application.create({
  LOG_TRANSITIONS: true,
  LOG_ACTIVE_GENERATION: true,
  LOG_TRANSITIONS_INTERNAL: true
});

Todos.ApplicationAdapter = DS.RESTAdapter.extend({
	namespace : 'todoSRV_NOSQL-V0.0.1/api/1/app',
	beforeSend: function(xhr) { xhr.setRequestHeader('Accept', 'application/json'); }
});

CREATE: HTTP request sample:

POST http://localhost:8080/todoSRV_NOSQL-V0.0.1/api/1/app/todos/
    associated request data: source {"todo":{"title":"aa","isCompleted":false}}

HTTP Response : (201 CREATED)
   associated response data: {"todo":{"id":"5249502025c4a43c241b4ecf","title":"aa","isCompleted":"false"}}

UPDATE: HTTP request sample:

PUT http://localhost:8080/todoSRV_NOSQL-V0.0.1/api/1/app/todos/5249502025c4a43c241b4ecf
    associated request data: source {"todo":{"title":"aa","isCompleted":true}}
	
HTTP Response : (200 OK)
   associated response data: {"todo":{"id":"5249502025c4a43c241b4ecf","title":"aa","isCompleted":"true"}}

I’am applying “Ember REST Data’s Protocol” as described in this article, so I do not understand the trick.

Do you have any idea ? thanks !!


#2

Hello everybody,

I tried with the “ActiveModelAdapter” too (the server response format / behavior is the same except for “isCompleted” -> “is_completed” attribute) but I have the same ember-data behavior : ember-data do not seems to understand the server response and re-send the request again and again and again…

Can you please help me ?

I do not find the place in ember-data code where the decision to resend the response is made…

Best regards


#3

Did you ever find a fix for this? I’m experiencing the same issue, I even renamed the “is_completed” field to just “completed” in my database just to see if it had something to do with the snake-case convention but same problem.

Editing the todo text works fine which is weird.