ember-data

Ember data rendering hasMany

ぃ、小莉子 提交于 2019-12-23 20:16:36
问题 In my ember app I have a models: App.Schedule = DS.Model.extend({ manager:DS.belongsTo('App.Manager', { embedded: true }), entries:DS.hasMany('App.Reservation', { embedded: true }) }); App.Reservation = DS.Model.extend({ name:DS.attr('string') }); and a handelbars view: {{#each schedule in controller}} <td> {{#each reservation in schedule.entries)}} <div>{{reservation.name}}</div> {{/each}} </td> {{/each}} But with this view a've got exception Expecting 'ID', got 'undefined' This workaround

how to get Ember-Data RESTAdapter to send “hasMany” records to server

徘徊边缘 提交于 2019-12-23 20:12:27
问题 I'm using Ember-Data beta 3. My Ds.models are similar to the following: App.Item = DS.Model.extend({ itemName: DS.attr('string'), strategy: DS.belongsTo('strat') }); App.Strat = DS.Model.extend({ stratName: DS.attr('string'), items: DS.hasMany('item',{async:true}) }); Using Ember-data's RESTAdapter, I'm able to populate the model using data from my server. But when I tried to persist data back to the server, none of the "App.Item" records got sent. The JSON received by my server only

Ember.js Acceptance Testing not waiting for asynchronous data operations

你。 提交于 2019-12-23 19:52:04
问题 When using the Emberfire (Firebase) adapter, I'm getting various errors that indicate the tests are not waiting for data operations to complete. eg: Error: Assertion Failed: You can only unload a record which is not inFlight. when I try to create, check, and then delete a record Also: FIREBASE WARNING: Exception was thrown by user callback. Error: Called stop() outside of a test context at Object.extend.stop (http://localhost:4200/assets/test-support.js:3000:10) at exports.default.

Ember data model reload causes item in {{each}} to be removed/inserted back - losing current state

放肆的年华 提交于 2019-12-23 16:34:37
问题 How could I prevent the itemView from being removed and re-rendered back in place when iterating over a controller's arrangedContent , if the observed model's property doesn't change value? Short version below, using a blog post App.Post as example model: Controller: sortProperties: ['createdAt'] Template: {{each arrangedContent}} {{title}} {{body}} {{/each}} objectAt(0).reload() causes the corresponding item to be removed and inserted back in the same place. The problem is that the itemView

Find operation (AJAX request) rejected, not seen in the wire

梦想的初衷 提交于 2019-12-23 16:25:00
问题 In my application, I am doing several find operations. All of them are working, except one, which is being rejected. For debugging purposes, I am sending the requests during startup of the application: preloadData : function () { SettingsApp.Node.find(); SettingsApp.Locator.find(); SettingsApp.Phonelocation.find(); SettingsApp.User.find(CNST.ME_FAKE_DOC_ID); SettingsApp.Company.find(CNST.MY_ORG_FAKE_DOC_ID); }, And this is how it looks in the console: As you can see, all requests are

In ember data, calling destroyRecord in a forEach loop is corrupting the loop?

邮差的信 提交于 2019-12-23 15:17:31
问题 I'm working on a simple Tag model for one of my projects. I've implemented something similar in Angular, but I wanted to give it a try in Ember. The model code is below Tag = DS.Model.extend { name:DS.attr('string') user:DS.belongsTo('user') appliedTags:DS.hasMany('AppliedTag') obliterate:()-> #destory the associated applied tags this.get('appliedTags').forEach( (appliedTag)-> console.log(Ember.inspect(appliedTag)) appliedTag.destoryRecord() ) #destory the record this.destroyRecord() }

Node.js sequelize embed hasMany IDs

≯℡__Kan透↙ 提交于 2019-12-23 15:09:53
问题 I am experimenting with a Ember app using ember-data and a node.js backend serving data from MySQL using Sequelize.js. My problem: If I have a Comment model associated to a Post model through hasMany the expected JSON by ember-data looks like { "post": { "comment_ids": [1, 2, 3] } } What would be the best way to query / generate this JSON without expensive loops etc. using sequelize? The Comment model has a foreign key with the post_id. 回答1: I went for implementing it like: // include

Getting error: You need to pass a model name to the store's modelFor method

时间秒杀一切 提交于 2019-12-23 13:02:24
问题 Using Ember 2.6.0 Have the following routes defined: Router.map(function() { this.route('brands'); this.route('brand', {path: '/brands/:brand_id'}); }); The model for brand is: export default Model.extend({ name: attr('string'), description: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), regions: hasMany('region') }); And the model for region is: export default Model.extend({ name: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), brand: belongsTo(

Getting error: You need to pass a model name to the store's modelFor method

主宰稳场 提交于 2019-12-23 13:01:15
问题 Using Ember 2.6.0 Have the following routes defined: Router.map(function() { this.route('brands'); this.route('brand', {path: '/brands/:brand_id'}); }); The model for brand is: export default Model.extend({ name: attr('string'), description: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), regions: hasMany('region') }); And the model for region is: export default Model.extend({ name: attr('string'), dateCreated: attr('date'), lastUpdated: attr('date'), brand: belongsTo(

JSONAPI strong params with Rails and Ember

拜拜、爱过 提交于 2019-12-23 12:36:20
问题 I'm using Ember with ember-data and a rails api. I had a createRecord() and save() for the record that was working fine. The payload in the network tab for the post request to create the record in rails looks like: {data: {attributes: { foo: 'bar' } } . In the rails controller, I have strong params like so: params.require(:data).require(:attributes).permit(:foo) , which was working fine for a little while. Now when I send the request rails says that param is missing or the value is empty: