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

ember model validator breaks on ember-data 1.0.0-beta.19.1 #11

Closed
sescobb27 opened this issue Jun 24, 2015 · 3 comments
Closed

ember model validator breaks on ember-data 1.0.0-beta.19.1 #11

sescobb27 opened this issue Jun 24, 2015 · 3 comments
Assignees
Labels

Comments

@sescobb27
Copy link

in store.recordWasInvalid(this, errors); throws an error Uncaught TypeError: internalModel.adapterDidInvalidate is not a function.

reading the source code of ember-data I found this

// ===== InternalModel
// FOR USE DURING COMMIT PROCESS
/**
  @method adapterDidInvalidate
  @private
*/
adapterDidInvalidate: function (errors) {
  var recordErrors = this.getErrors();
  ember$data$lib$system$model$internal$model$$forEach.call(Ember.keys(errors), function (key) {
    recordErrors.add(key, errors[key]);
  });
  this._saveWasRejected();
}
// ===== InternalModel

/**
  This method is called once the promise returned by an
  adapter's `createRecord`, `updateRecord` or `deleteRecord`
  is rejected with a `DS.InvalidError`.
   @method recordWasInvalid
  @private
  @param {InternalModel} internalModel
  @param {Object} errors
*/
recordWasInvalid: function (internalModel, errors) {
  internalModel.adapterDidInvalidate(errors);
}

I think you should not call that method manually, instead make something like this: https://github.com/dockyard/ember-validations/blob/master/addon/validators/local/inclusion.js#L23

@esbanarango esbanarango self-assigned this Jun 24, 2015
@sescobb27
Copy link
Author

emberjs/data#3262 try to fix it for similar issue

@esbanarango
Copy link
Owner

@sescobb27 This PR by @davidstevens37 should solve this issue. (Thank you @davidstevens37 )

@esbanarango
Copy link
Owner

@sescobb27 Could you confirm it pls. Thank you!

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