Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find method doesn't communicate with the server after error returned. #1235

Closed
xenyou opened this issue Sep 6, 2013 · 1 comment
Closed

Comments

@xenyou
Copy link

xenyou commented Sep 6, 2013

Here is the sample code.
And try pushing the 'fire' button in your browser twice.

If the server returns some error (e.g. 401), you will see 'failed' in console at the first time. But the second time, you will see 'success' and 'undefined' in console without communicating with the server.

App = Ember.Application.create({ });
App.Router.map(function() {
  this.route('users', {path: '/'})
});
App.UsersRoute= Em.Route.extend({
  model: function() { return [1,2,3]; },
});

App.UsersController = Em.ArrayController.extend({
  actions: {
    fire: function() {
      this.store.find('user', 0).then(function(user) {
        console.log('success');
        console.log(user.get('name'));
      }, function() {
        console.log('failed');
      });
    }
  },
});

App.Store = DS.Store.extend({ adapter: DS.RESTAdapter, });
App.User = DS.Model.extend({ name: DS.attr('string'), });

Em.TEMPLATES['users'] = Em.Handlebars.compile('' +
    '<button {{action fire}}>fire</button>'
);

Is it a bug?

@wycats
Copy link
Member

wycats commented Sep 6, 2013

Oooh interesting. I think the issue is that we only check whether records are empty before triggering the fetch, but these records are in error. I have some ideas.

@wycats wycats closed this as completed in 63795a4 Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants