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) {
|
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];
|
||||||
var pathName = (relation.options.http && relation.options.http.path) || relationName;
|
var pathName = (relation.options.http && relation.options.http.path) || relationName;
|
||||||
define('__get__' + relationName, {
|
define('__get__' + relationName, {
|
||||||
|
@ -353,7 +355,7 @@ Model.belongsToRemoting = function(relationName, relation, define) {
|
||||||
http: {verb: 'get', path: '/' + pathName},
|
http: {verb: 'get', path: '/' + pathName},
|
||||||
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