Last active
March 30, 2016 17:27
-
-
Save pablobm/e820604c62b94a5828d6890d2e37efe2 to your computer and use it in GitHub Desktop.
Delete records with errors
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
init() { | |
this.store.createRecord('line', {name: "yksi"}); | |
this.store.createRecord('line', {name: "kaksi"}); | |
this.store.createRecord('line', {name: "kolme"}); | |
}, | |
lines: Ember.computed(function() { | |
return this.store.findAll('line'); | |
}), | |
actions: { | |
invalidate(line) { | |
// No problem if I use this to add the error | |
//line.get('errors')._add('name', "is not up to scratch"); | |
// Recklessly using private APIs in order | |
// to reproduce the problem with minimum code | |
this.store.recordWasInvalid( | |
line._internalModel, { | |
name: "is not up to scratch", | |
} | |
); | |
}, | |
delete(line) { | |
line.deleteRecord(); | |
}, | |
}, | |
}); |
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
import DS from 'ember-data'; | |
export default DS.Model.extend({ | |
line: DS.attr('string'), | |
}); |
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
{ | |
"version": "0.7.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment