Entire error:
Uncaught Error: Assertion Failed: You may not set `id` as an attribute on your model. Please remove any lines that look like: `id: DS.attr('<type>')` from App.Plan
Ember Model:
App.Plan = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string'),
period: DS.attr('number'),
price: DS.attr('number')
});
Data coming from REST API:
{"plans":[{"id":1,"name":"Monthly subscription","period":1,"price":2}]}
Question: How can I move around the above error ?
Just leave out the id
attribute from your DS.Model
. Ember-data automatically handles that for you. You'll still be able to find the record using the id, and it'll be a property on the object when you access it from within your Ember application. See here and here for more info.
App.Plan = DS.Model.extend({
name: DS.attr('string'),
period: DS.attr('number'),
price: DS.attr('number')
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With