Don't assume relation.modelTo in case of polymorphic belongsTo
This commit is contained in:
parent
b3fbefdbb7
commit
1af95272fe
|
@ -342,13 +342,15 @@ Model.remoteMethod = function(name, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Model.belongsToRemoting = function(relationName, relation, define) {
|
Model.belongsToRemoting = function(relationName, relation, define) {
|
||||||
|
var modelName = relation.modelTo && relation.modelTo.modelName;
|
||||||
|
modelName = modelName || 'PersistedModel';
|
||||||
var fn = this.prototype[relationName];
|
var fn = this.prototype[relationName];
|
||||||
define('__get__' + relationName, {
|
define('__get__' + relationName, {
|
||||||
isStatic: false,
|
isStatic: false,
|
||||||
http: {verb: 'get', path: '/' + relationName},
|
http: {verb: 'get', path: '/' + relationName},
|
||||||
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
||||||
description: 'Fetches belongsTo relation ' + relationName,
|
description: 'Fetches belongsTo relation ' + relationName,
|
||||||
returns: {arg: relationName, type: relation.modelTo.modelName, root: true}
|
returns: {arg: relationName, type: modelName, root: true}
|
||||||
}, fn);
|
}, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue