lib/assets/javascripts/backbone_extensions/associations.js in backbone_extensions-0.0.12 vs lib/assets/javascripts/backbone_extensions/associations.js in backbone_extensions-0.0.13

- old
+ new

@@ -68,14 +68,14 @@ } if (options.parse) { var associations = { hasMany: function(assocResponse, association, newOptions) { - association.add(_(assocResponse).map(function(response) { return association.parse(response); }), newOptions); + association.add(_(assocResponse).compact(), newOptions); }, hasOne: function(assocResponse, association, newOptions) { - association.clear({silent: true}).set(association.parse(assocResponse), newOptions); + association.clear({silent: true}).set(assocResponse, newOptions); } }; if (associations[associationType]) { var parseFunc = _(options.parse).isFunction() && @@ -105,11 +105,12 @@ }); } this._parsers.push({ parseFn: parseFunc, - associationFn: function(assocResponse) { - associations[associationType].call(this, assocResponse, this[associationName](), mergeAssociationOptions(options, this._options)); + associationFn: function(response) { + var association = this[associationName](); + return associations[associationType].call(this, association.parse(response), association, mergeAssociationOptions(options, this._options)); } }); } } }