Created
May 23, 2012 08:21
-
-
Save joachimhs/2773865 to your computer and use it in GitHub Desktop.
No Primary Key
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
Model: | |
MyApp.Photo = DS.Model.extend({ | |
primaryKey: 'id', | |
id: DS.attr('string'), | |
photoName: DS.attr('string'), | |
photoDescription: DS.attr('string'), | |
photoFullSizeURL: DS.attr('string'), | |
photoThumbnailURL: DS.attr('string') | |
}); | |
JSON retrieved from server: | |
[ | |
{ | |
"id": "1", | |
"photoName": "Bird Photo", | |
"photoDescription": "Bird Photo Description", | |
"photoFullSizeUrl": "photos/bird.jpg", | |
"photoThumbnailUrl": "photos/bird_thumb.png" | |
} | |
] | |
Adaptor for findAll: | |
MyApp.Adapter = DS.Adapter.create({ | |
findAll: function(store, type) { | |
var url = type.url; | |
jQuery.getJSON(url, function(data) { | |
console.log('getting from url: ' + url + ' length: ' + data.length); | |
store.loadMany(type, data); | |
}); | |
} | |
}); | |
Error Message: | |
Error: assertion failed: A data hash was loaded for a model of type MyApp.Photo but no primary key 'undefined' was provided. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment