the page load starts at when a user is viewing a user's profile. And he makes some action and my code does ajax call to update it's user type-
App.UserController = Ember.ObjectController.extend
convert: ->
$.get '/api/user/convert_to_client/' + id, (response) ->
self.set('user_type', response.user.user_type)
But whenever i go to the user listing table and Ember tries to fetch all the users from the UsersRoute:
module.exports = App.UsersRoute = Em.Route.extend
model: ->
App.User.find({}).then (response) ->
self.controllerFor('users').set('content', response)
Then i end up getting all errors similar to these:
Error Attempted to handle event `loadedData` : Object not updated after deleteRecord
I think this article here explains the issue -
http://www.thomasboyt.com/2013/05/01/why-ember-data-breaks.html
Uncaught Error: Attempted to handle event
loadedData
on while in state rootState.loaded.updated.uncommitted. Called with {}What this means is that you're trying to do something to the record that it can't do in its current state. This often happens when trying to update a record that's currently saving or when trying to render a property on an object that's been deleted.
But note that when its the other way around, I first go to the user listing table, and then go and view a user's profile, update the user - this error never comes out.
Edit:
Sample response from users:
{
users: [
{
_id: 521e1112e8c5e10fb40002a0
..
}
]
}
and for a single user:
{
user: {
_id: 521e1116e8c5e10fb40004ca
}
}