Note that there are some explanatory texts on larger screens.

plurals
  1. POEmberjs Embedded models but Adapter.map does not exist
    primarykey
    data
    text
    <p>The <a href="http://emberjs.com/guides/models/defining-models/#toc_embedded-objects" rel="nofollow">emberjs guide</a> says the following about nesting models:</p> <blockquote> <p>When you have a data structure where the embedded data doesn't use or need ids, you have to specify that the belongsTo relationship is contained by the hasMany relationship.</p> <p>To do this, you need to extend the adapter that your app is using to load the data with the embedded structure.</p> </blockquote> <pre><code>App.Comment = DS.Model.extend({}); App.Post = DS.Model.extend({ comments: DS.hasMany('comment') }); App.Adapter.map('post', { comments: { embedded: 'always' } }); </code></pre> <p>I'm using the restAdapter so I thought doing this would be correct:</p> <pre><code>App.Adapter.map('checkData', { //'App.CheckData' isn't working either items: { embedded: 'always' } }); </code></pre> <p>But then I get the following error: (tldr; DS.RESTAdapter has no method 'map')</p> <pre><code>Uncaught TypeError: Object function () { if (!wasApplied) { Class.proto(); // prepare prototype... } o_defineProperty(this, GUID_KEY, undefinedDescriptor); o_defineProperty(this, '_super', undefinedDescriptor); var m = meta(this), proto = m.proto; m.proto = this; if (initMixins) { // capture locally so we can clear the closed over variable var mixins = initMixins; initMixins = null; this.reopen.apply(this, mixins); } if (initProperties) { // capture locally so we can clear the closed over variable var props = initProperties; initProperties = null; var concatenatedProperties = this.concatenatedProperties; for (var i = 0, l = props.length; i &lt; l; i++) { var properties = props[i]; Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Ember.Mixin)); for (var keyName in properties) { if (!properties.hasOwnProperty(keyName)) { continue; } var value = properties[keyName], IS_BINDING = Ember.IS_BINDING; if (IS_BINDING.test(keyName)) { var bindings = m.bindings; if (!bindings) { bindings = m.bindings = {}; } else if (!m.hasOwnProperty('bindings')) { bindings = m.bindings = o_create(m.bindings); } bindings[keyName] = value; } var desc = m.descs[keyName]; Ember.assert("Ember.Object.create no longer supports defining computed properties.", !(value instanceof Ember.ComputedProperty)); Ember.assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' &amp;&amp; value.toString().indexOf('._super') !== -1)); Ember.assert("`actions` must be provided at extend time, not at create time, when Ember.ActionHandler is used (i.e. views, controllers &amp; routes).", !((keyName === 'actions') &amp;&amp; Ember.ActionHandler.detect(this))); if (concatenatedProperties &amp;&amp; indexOf(concatenatedProperties, keyName) &gt;= 0) { var baseValue = this[keyName]; if (baseValue) { if ('function' === typeof baseValue.concat) { value = baseValue.concat(value); } else { value = Ember.makeArray(baseValue).concat(value); } } else { value = Ember.makeArray(value); } } if (desc) { desc.set(this, keyName, value); } else { if (typeof this.setUnknownProperty === 'function' &amp;&amp; !(keyName in this)) { this.setUnknownProperty(keyName, value); } else if (MANDATORY_SETTER) { Ember.defineProperty(this, keyName, null, value); // setup mandatory setter } else { this[keyName] = value; } } } } } finishPartial(this, m); this.init.apply(this, arguments); m.proto = proto; finishChains(this); sendEvent(this, "init"); } has no method 'map' app.js:96 (anonymous function) </code></pre> <p>So I checked whether it would be correct to call the map function on the RestAdapter. But on a <a href="http://emberjs.com/guides/models/the-rest-adapter/#toc_underscored-attribute-names" rel="nofollow">different page</a> I find this:</p> <pre><code>App.Person = DS.Model.extend({ lastName: DS.attr('string') }); DS.RESTAdapter.map('App.Person', { lastName: { key: 'lastNameOfPerson' } }); </code></pre> <p>Is the documentation wrong? </p> <p>PS:</p> <pre><code>DEBUG: Ember.VERSION : 1.0.0 ember-1.0.0.js:394 DEBUG: Handlebars.VERSION : 1.0.0 ember-1.0.0.js:394 DEBUG: jQuery.VERSION : 1.9.1 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload