Given the following code snippets, Ember.js keeps hitting the following alert everytime I press the update button on Edit.hbs while in development mode:
alert('failed to update user!')
However, what makes this issue different is that the record is persisted on the server side with a 200 (M'kay)
reply, and when I am in production mode with my live website, Ember.js confirms that the user has been updated with the other alert()... Any thoughts on what could be the source of this issue?
I have seen quite a few examples around, but I am suspecting that most of them are no longer valid for the 2.0 ember versions...
Router
this.route('user', { path:'user/:user_id' }, function() {
this.route('edit');
});
Edit Controller
// Removed extra code that controls warning messages to model.user
// and comparison to model.users
update: function(user) {
// Extra Code that checks current_password and others omitted.
user.save().then(function() {
alert('User Updated!');
// transitionToRoute errors with undefined...
this.controller.transitionToRoute('user', user);
}, function() {
alert('failed to update user!');
});
}
Edit Route
export default Ember.Route.extend ({
model: function() {
return Ember.Object.create ({
user: this.modelFor('user'),
users: this.store.findAll('user')
});
}
});
Edit Template (Button Only)
<button class="button_type1" {{action "update" model.user}}>Update User</button>
Live Website
This will take you directly to User #2 edit page. At the moment you will have unrestricted access to the website as this will make it easier for bug hunting... Changing password is not working, but the other attributes should persist as discussed previously.
Source Code
Aucun commentaire:
Enregistrer un commentaire