Last active
May 4, 2016 16:19
-
-
Save orestis/f57e4bff221997a87f51 to your computer and use it in GitHub Desktop.
normalize issue
This file contains 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({ | |
appName: 'Ember Twiddle', | |
response: '{"data":{"id":"35","type":"file-upload","attributes":{"file":"http://example.com/somefile"}, "relationships":{}}}', | |
data: null, | |
normal: null, | |
objPush: null, | |
objPushPayload: null, | |
actions: { | |
save: function() { | |
var response = this.get("response"); | |
var data = JSON.parse(response); | |
this.set("data", JSON.stringify(data, null, 4)); | |
console.log(data); | |
this.store.pushPayload(data); | |
var obj = this.store.peekRecord("file-upload", 35); | |
this.set("objPushPayload", obj); | |
// I believe the following should work as well: | |
//var normal = this.store.normalize("file-upload", data); | |
var normal = this.store.normalize("file-upload", data.data); | |
console.log(normal); | |
this.set("normal", JSON.stringify(normal, null, 4)); | |
var objPush = this.store.push(normal); | |
this.set("objPush", objPush); | |
} | |
} | |
}); |
This file contains 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({ | |
file: DS.attr("string") | |
}); |
This file contains 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