Created
June 19, 2012 17:49
-
-
Save pivotal-medici/2955527 to your computer and use it in GitHub Desktop.
Deleting only unsaved child in relationship throws exception
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<script src="/jquery.js" type="text/javascript"></script> | |
<script src="/handlebars.js" type="text/javascript"></script> | |
<script src="/ember.js" type="text/javascript"></script> | |
<script src="/ember-data.js" type="text/javascript"></script> | |
<script src="/test.js" type="text/javascript"></script> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Definitions */ | |
App = Em.Application.create({ | |
store: DS.Store.create({ | |
revision: 4, | |
adapter: DS.RESTAdapter.create({ | |
bulkCommit: false | |
}) | |
}) | |
}); | |
App.Lesson = DS.Model.extend({ | |
cards: DS.hasMany('App.Card') | |
}); | |
App.Card = DS.Model.extend(); | |
/* Setup */ | |
var lesson = App.Lesson.createRecord(); | |
var card1 = App.Card.createRecord(); | |
lesson.get('cards').pushObject(card1); | |
lesson.get('cards').removeObject(card1); | |
// This throws an exception if it's the last one | |
// in the association and it wasn't saved | |
card1.deleteRecord(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment