Skip to content

Commit

Permalink
assertion must be in primary init
Browse files Browse the repository at this point in the history
  • Loading branch information
runspired committed Apr 21, 2021
1 parent 6bcf40a commit 7c95440
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/model/addon/-private/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ class Model extends EmberObject {
init(...args) {
super.init(...args);

if (DEBUG) {
if (!this._internalModel) {
throw new EmberError(
'You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.'
);
}
}

if (RECORD_DATA_ERRORS) {
this._invalidRequests = [];
}
Expand Down Expand Up @@ -2259,12 +2267,6 @@ if (DEBUG) {
init() {
this._super(...arguments);

if (!this._internalModel) {
throw new EmberError(
'You should not call `create` on a model. Instead, call `store.createRecord` with the attributes you would like to set.'
);
}

if (DEPRECATE_EVENTED_API_USAGE) {
this._getDeprecatedEventedInfo = () => `${this._internalModel.modelName}#${this.id}`;
}
Expand Down

0 comments on commit 7c95440

Please sign in to comment.