在Ember Data 1的修订版3中,you could set the foreign key:
App.Model = DS.Model.extend({
namingConvention: {
// LOUD NAMING CONVENTION
// Changes fooKey to FOOKEY
keyToJSONKey: function(key) {
return key.toUpperCase();
},
// Determines the name of foreign keys in
// belongsTo relationships
foreignKey: function(key) {
return key.toUpperCase()+"_ID";
}
}
});
现在似乎不起作用(目前版本7)。你如何设置外键?
答案 0 :(得分:0)
您可能正在寻找keyForBelongsTo
。见http://emberjs.com/api/data/classes/DS.RESTSerializer.html
App.ApplicationSerializer = DS.RESTSerializer.extend({
keyForBelongsTo: function(type, name) {
return this.keyForAttributeName(type, name) + "_id";
},
});