ember-data

Ember data saving a relationship

天大地大妈咪最大 提交于 2020-01-09 03:19:12
问题 I'm having difficult saving a one-to-many relationship in ember data. I have a relationship like this: App.ParameterSet = DS.Model name: DS.attr("string") regions: DS.hasMany("App.Region") App.Region = DS.Model name: DS.attr("string") If I were to do something like this: parameterSet = App.ParameterSet.find(5) @transaction = @get("store").transaction() @transaction.add(parameterSet) region1 = App.Region.find(10) region2 = App.Region.find(11) parameterSet.set("name", "foo") parameterSet.get(

Serialize ids when saving emberjs model

放肆的年华 提交于 2020-01-07 05:28:06
问题 I have an emberjs application backed by a nodejs server and mongodb . Currently my database is sending documents with an '_id' field. I have the followign code to force Ember to treat '_id' as the primary key : App.ApplicationSerializer = DS.RESTSerializer.extend({ primaryKey: '_id' }); On the other hand i have two models related by a 'hasMany' relationship as such: App.Player = DS.Model.extend({ name: DS.attr('string'), thumbLink: DS.attr('string'), activeGame: DS.belongsTo('game', { async:

Display JSON Api conform errors

北战南征 提交于 2020-01-07 05:25:25
问题 I receive JSON Api conform errors from the backend: { "errors": [ { "status": "400", "source": { "pointer": "/data/attributes/description" }, "detail": "This field may not be null." }, { "status": "400", "source": { "pointer": "/data/attributes/due-date" }, "detail": "This field may not be null." }, { "status": "400", "source": { "pointer": "/data/attributes/extra-comments" }, "detail": "This field may not be null." }, { "status": "400", "source": { "pointer": "/data/attributes/name" },

POST request to API from Ember often fails with 'The adapter operation was aborted Error'

无人久伴 提交于 2020-01-07 04:14:08
问题 I'm writing an Ember tutorial that I'd like to run on top of a very simple API I've created in Flask. PUT, DELETE, and GET requests made from ember-data behave as expected. The POST request throws an error and does not complete. The POST Ajax request is canceled before it's sent. This behavior is intermittent. If I set a breakpoint and follow it through the Ember internals then by the time I'm done, the request will often succeed. When running the API locally the error is thrown but the new

Ember store query template no model data

别说谁变了你拦得住时间么 提交于 2020-01-06 20:25:15
问题 How come Ember model store query doesn't update template model data and find does? // This doesn't update the template, when loading website no information is displayed but the data is loaded model: function() { var parentModel = this.modelFor("server.view"); return this.store.query("server", { server_address: parentModel.server_address }); } // This works without any problems model: function() { var parentModel = this.modelFor("server.view"); return this.store.find("server", 1); } 回答1: So I

Getting “Error: Assertion Failed: calling set on destroyed object” when trying to rollback a deletion

余生颓废 提交于 2020-01-06 08:26:16
问题 I am looking into how to show proper deletion error message in ember when there is an error coming back from the server. I looked at this topic and followed its suggestion: Ember Data delete fails, how to rollback My code is just like it, I return a 400 and my catch fires and logs, but nothing happens, when I pause it in the debugger though and try to rollback, I get Error: Assertion Failed: calling set on destroyed object So A) I cannot rollback B) the error is eaten normally. Here is my

Accessing a service's promise from a route

空扰寡人 提交于 2020-01-06 04:00:06
问题 I am struggling to a Service's promised data in a Route. The problem occurs when I am transitioning to the Route at application init; that is, if I load the application, then transition, everything is fine, because the promise is already fulfilled, but if I hit browser reload on that Route, the offending lines won't run. The Service is: // services/lime-core.js import Ember from 'ember'; export default Ember.Service.extend({ store: Ember.inject.service(), resources: null, init() { this.set(

Where did my data get stuck in Ember? <!---->

大城市里の小女人 提交于 2020-01-05 10:08:21
问题 I'm trying to learn ember but having a hard time finding out why my data from the backend is not showing up. I'm using Ember Data with mirage fixtures. The data is showing up. Only if I introduce simple relationships the data from those relationships is not showing up in my app. Is there a general way how to debug when you just get <!----> in your ember app? mirage/fixtures/contacts.js export default [ { id: 1, userName: "Barack Obama", profilePictureUrl: "/img/profilepics/barack.png",

Embedded objects in fixtures raise “unable to find fixtures” errors

情到浓时终转凉″ 提交于 2020-01-05 08:31:21
问题 I'm using ember-data's fixtures adapter extensively to provide a lot of set-up data in my app. For one model ("Structure"), there is an array of embedded related objects ("Overlays"). When I load a Structure instance from the store, then query its overlays property, I get this error: Uncaught Error: assertion failed: Unable to find fixtures for model type App.Overlay Both models are defined as follows (with a few other fields/relationships removed for clarity): App.Structure = DS.Model.extend

Embedded objects in fixtures raise “unable to find fixtures” errors

99封情书 提交于 2020-01-05 08:29:21
问题 I'm using ember-data's fixtures adapter extensively to provide a lot of set-up data in my app. For one model ("Structure"), there is an array of embedded related objects ("Overlays"). When I load a Structure instance from the store, then query its overlays property, I get this error: Uncaught Error: assertion failed: Unable to find fixtures for model type App.Overlay Both models are defined as follows (with a few other fields/relationships removed for clarity): App.Structure = DS.Model.extend