Issue with parsing an `has().one()` association on creation #32

ShayDavidson opened this Issue May 19, 2013 · 4 comments

5 participants


I migrated my code to Supermodel and I have problems with the original Backbone's parse method and the association.

This is my configuration:

MainObject.has().one('smaller_obj', {
    model: SmallerObject,
    inverse: 'main_object'

The JSON I create my main object is:

   id: Z,
   attr1: ...,
   smaller_obj: {id: X, attr_1: ... , attr_2: ...}

SmallerObject has a parse method that performs a transformation on the attributes before assigning them to the new model. The problem is, that its parse method is called with an object containing only the id property, and not the rest of the attributes.

After a little research, I noticed that the parse: true option is not passed on to associations in the create method.

obj = MainObject.create(objData, {parse: true});

Parses the main object, but not its associations.

I 'hacked' this for now by adding a parse:true option when creating association models, but obviously this is not the right solution. It also does not prevent the other call to parse which only contains the id attribute (I get one call to parse at creation with all the attributes and another later with only the id property).


We have this same issue. Is there some reason it's not passing parse:true?





@braddunbar braddunbar closed this in #47 Feb 4, 2014

Apologies for the delay, fixed up in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment