Merge pull request #449 from fabien/fix/polymorphic-belongs-to
Don't assume relation.modelTo in case of polymorphic belongsTo
This commit is contained in:
commit
b07aac7377
|
@ -346,6 +346,8 @@ Model.remoteMethod = function(name, options) {
|
|||
}
|
||||
|
||||
Model.belongsToRemoting = function(relationName, relation, define) {
|
||||
var modelName = relation.modelTo && relation.modelTo.modelName;
|
||||
modelName = modelName || 'PersistedModel';
|
||||
var fn = this.prototype[relationName];
|
||||
var pathName = (relation.options.http && relation.options.http.path) || relationName;
|
||||
define('__get__' + relationName, {
|
||||
|
@ -353,7 +355,7 @@ Model.belongsToRemoting = function(relationName, relation, define) {
|
|||
http: {verb: 'get', path: '/' + pathName},
|
||||
accepts: {arg: 'refresh', type: 'boolean', http: {source: 'query'}},
|
||||
description: 'Fetches belongsTo relation ' + relationName,
|
||||
returns: {arg: relationName, type: relation.modelTo.modelName, root: true}
|
||||
returns: {arg: relationName, type: modelName, root: true}
|
||||
}, fn);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue