I found that if I try to include the url in the original definition of an ember-data model it blows up in my REST adapter but if I simply "reopenClass" it's fine.
What is the technical reason behind this? (below is the working example)
CodeCamp.Speaker = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string'),
session: DS.belongsTo('CodeCamp.Session')
});
CodeCamp.Speaker.reopenClass({
url: 'sessions/%@/speakers'
});
Calling extend
on an object sets instance attributes, whereas reopenClass
sets class attributes.
The url
attribute is a class-level attribute,
Ember.get(CodeCamp.Speaker, 'url')
as opposed to:
speaker = CodeCamp.Speaker.createObject()
Ember.get(speaker, 'name')
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