after I change to Backbone-Relational my model stopped to work when I call destroy().. I have to ensure that when it removes success on server there will be no more id at client side, so then when I try to save it again my model wont request PUT (update) – throws Record Not Found on server side.
Coffeescript side
save: ->
if isBlank @model.get("text")
@model.destroy() # after success it still with same attributes including id!!
else
@model.save()
Rails side
def destroy
@note = Note.find(params[:id])
@note.destroy
respond_with @note # callback is empty
end
Bug from Backbone-Relational perhaps? Does Backbone.js update id after destroy?
Backbone does not look like it modifies the Model on destruction in any way. Except removing it from its collection if any.
Check the code
What it does is triggering the event
destroyso you easily can listen this event and do whatever you think is the proper behavior in destruction: