Skip to content

Commit

Permalink
Use findOrCreate instead of build in fetchRelated, to prevent i…
Browse files Browse the repository at this point in the history
…nstantiation errors. Fixes #186.
  • Loading branch information
PaulUithol committed Nov 28, 2012
1 parent f26d88b commit d19e7e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backbone-relational.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,12 +1194,12 @@
var model;

if ( _.isObject( item ) ) {
model = rel.relatedModel.build( item );
model = rel.relatedModel.findOrCreate( item );
}
else {
var attrs = {};
attrs[ rel.relatedModel.prototype.idAttribute ] = item;
model = rel.relatedModel.build( attrs );
model = rel.relatedModel.findOrCreate( attrs );
}

return model;
Expand Down

0 comments on commit d19e7e7

Please sign in to comment.