@@ -196,12 +196,16 @@ export default Ember.Object.extend(FetchMixin, Evented, {
196
196
return RSVP . Promise . resolve ( null ) ;
197
197
}
198
198
json = json || { data : { id : resource . get ( 'id' ) , type : resource . get ( 'type' ) } } ;
199
- json . data . relationships = relationships ;
199
+ let cleanup = Ember . K ;
200
+ if ( relationships ) {
201
+ json . data . relationships = relationships ;
202
+ cleanup = resource . _resetRelationships . bind ( resource ) ;
203
+ }
200
204
return this . fetch ( url , {
201
205
method : 'PATCH' ,
202
206
body : JSON . stringify ( json ) ,
203
207
update : true
204
- } ) ;
208
+ } ) . then ( cleanup ) ;
205
209
} ,
206
210
207
211
/**
@@ -248,7 +252,7 @@ export default Ember.Object.extend(FetchMixin, Evented, {
248
252
return this . fetch ( this . _urlForRelationship ( resource , relationship ) , {
249
253
method : 'POST' ,
250
254
body : JSON . stringify ( this . serializer . serializeRelationship ( resource , relationship , id ) )
251
- } ) ;
255
+ } ) . then ( resource . _resetRelationships . bind ( resource ) ) ;
252
256
} ,
253
257
254
258
/**
@@ -288,7 +292,7 @@ export default Ember.Object.extend(FetchMixin, Evented, {
288
292
return this . fetch ( this . _urlForRelationship ( resource , relationship ) , {
289
293
method : 'PATCH' ,
290
294
body : JSON . stringify ( this . serializer . serializeRelationship ( resource , relationship ) )
291
- } ) ;
295
+ } ) . then ( resource . _resetRelationships . bind ( resource ) ) ;
292
296
} ,
293
297
294
298
/**
@@ -318,7 +322,7 @@ export default Ember.Object.extend(FetchMixin, Evented, {
318
322
return this . fetch ( this . _urlForRelationship ( resource , relationship ) , {
319
323
method : 'DELETE' ,
320
324
body : JSON . stringify ( this . serializer . serializeRelationship ( resource , relationship , id ) )
321
- } ) ;
325
+ } ) . then ( resource . _resetRelationships . bind ( resource ) ) ;
322
326
} ,
323
327
324
328
/**
0 commit comments