Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Loading… resolves lazy-loaded attribute before PUT #1312

abobwhite opened this Issue · 2 comments

2 participants


Using Ember Data Canary Build from 9/16/13

I have a model that lazy-loads its products so I don't have to GET them when I don't need them:

App.Supplier = DS.Model.extend({
  products: DS.hasMany('product', {async : true}),

On a particular template, a Supplier can edit their profile (which does not need their "products"). After modifying attributes, I call to persist those changes. Normally (without the lazy-loaded attribute), this works fine. However, with adding in products: DS.hasMany('product', {async : true}),, when is called, there is first a GET for the products which is specified in the links hash. The GET resolves and the PUT resolves, however, due to my cookie security, every call to the server changes the cookie to prevent cookie theft. Since this GET is made out-of-band, it causes issues with the actual PUT thinking the cookie has been stolen since the GET doesn't return before the PUT takes place.

The main issue I have: Why does trigger a GET for the lazy-loaded products? I don't need them, I don't want them - why is ember data trying to get them for me?


Thanks to @wycats , I was able to use this workaround:

App.ApplicationSerializer = DS.RESTSerializer.extend({
  serializeHasMany: function(record, json, relationship) {
    if (relationship.options.async) { return; }

    return this._super.apply(this, arguments);

The correct semantics here probably depend on whether the async relationship is loaded, and whether it is strictly needed in order to save. I'm going to continue to leave this up to customizations in the adapter for a while and see what common semantics we can extract.

@wycats wycats closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.