Reputation: 203
I have a User Model defined as an Object.Model
import Ember from "ember";
export default Ember.Object.extend({
apiKey: null,
userId: null,
firstName: null,
lastName: null,
birthday: null,
gender: null,
city: null,
state: null,
email: null
});
I have a sign_up controller which makes an POST request to an API to register a new user. If the ajax post returns successfully, I want to create a new user instance with this line: self.store.createRecord({userId: response["user"]["id"], email: response["user"]["email"]});
In my router.js file, I have:
Router.UsersSignUpRoute = Ember.Route.extend({
model: function() {
return this.store.find('user');
}
});
When the register POST returns, I get the error Uncaught Error: Assertion Failed: {userId: 1, email: [email protected], store: <app@store:main::ember370>} does not appear to be an ember-data model
Upvotes: 1
Views: 512
Reputation: 18597
You need to include the model type as the first argument when calling createRecord
, then you should be good to go.
self.store.createRecord('user', {userId: response["user"]["id"], email: response["user"]["email"]});
Here's the documentation for createRecord
Upvotes: 1