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

saveWithAttachment is resolving to failure callback #30

Open
jgadbois opened this issue Nov 3, 2015 · 2 comments
Open

saveWithAttachment is resolving to failure callback #30

jgadbois opened this issue Nov 3, 2015 · 2 comments
Assignees
Labels

Comments

@jgadbois
Copy link
Contributor

jgadbois commented Nov 3, 2015

I'm calling model.saveWithAttachment which is returning a 200 with a JSON response, but it's going to the failure callback.

With .save it goes to the success callback.

Any ideas why the discrepancy?

@esbanarango esbanarango added the bug label Nov 3, 2015
@esbanarango esbanarango self-assigned this Nov 3, 2015
@esbanarango
Copy link
Collaborator

@jgadbois Could you provide more info about this bug. Ember version, ember data version, response, code example... etc. Thank you.

@jgadbois
Copy link
Contributor Author

jgadbois commented Nov 3, 2015

DEBUG: Ember      : 1.13.7
DEBUG: Ember Data : 1.13.9
DEBUG: jQuery     : 1.11.3

Response Information (same behavior when returning no JSON and returning JSON object)

Request URL:http://localhost:3000/api/v2/groups/356
Request Method:PUT
Status Code:200 OK
//model
var Group = DS.Model.extend(Attachable, {
  attachmentAs: ['image'],
  ...
});

// controller
// when file is added i send an event from the component containing the Blob - set in model like this
this.set('model.image', image);

// later on i save the model like this - second call back is being hit.
this.get('model').saveWithAttachment().then(function(result) {
   controller.set('saving', false);
   controller.transitionToRoute('dashboard.trainer.groups')
}, function(errors) {
   controller.set('saving', false);
   if(errors.errors) {
      controller.set('errorMessages', errors.errors);
   } else {
      controller.transitionToRoute('dashboard.trainer.groups')
   }
});


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants