I cannot seem to get ember-data to reject failed (404's) when using findQuery(..query..); find(..id..); works fine.
So in the route:
App.PostRoute = Ember.Route.extend({
serialize: function(model, params) {
return { post_id: model.get('slug') };
},
model: function(params){
var query = {};
query.slugs = params.post_id;
return App.Post.findQuery(query).then(
function (data) {
return data.get('firstObject');
},
function (error) {
console.log('error');
throw 'boom!';
}
)
},
setupController: function(controller, model){
this.controllerFor('post').set('content', model);
},
events: {
error: function (reason, transition) {
console.log('Error!');
}
}
});
I have also tried this:
return App.Post.findQuery(query).then( function (data) {
return data.get('firstObject');
}).then( null, function (error) {
console.log('error');
throw 'boom!';
});
No joy. I can see the request to the URL returning as 404, but the promises error is never triggered. What am I missing?
I don't know if it's only a typo, but the
events
hash in yourPostRoute
should be calledevents
you seam to have defined it as singularevent
this might be the problem why yourerror
hook inside that hash not getting found and this not invoked:Hope it helps.