将我的应用程序移至VPS后,我的应用程序停止工作。当我在浏览器中调用动作时,它将引发500错误'ReferenceError: <Model> is not defined'
。
奇怪的是,无论是否在docker容器中运行它,它在Mac上仍然可以完美运行。模型被设置为可在globals.js中全局访问。
一个不起作用的控制器:
module.exports = {
friendlyName: 'Players index',
description: 'Lists all players in a table',
inputs: {
},
exits: {
success: {
description: 'Renders index view',
responseType: 'view',
viewTemplatePath: 'pages/players-panel/index'
},
notFound: {
description: 'No players was found in the database.',
responseType: 'notFound'
}
},
fn: async function (inputs, exits) {
const models = await Players.find();
if (!models) { return exits.notFound(); }
return exits.success({players: models});
}
};
模型:
/**
* Players.js
*
* @description :: A model definition represents a database table/collection.
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
*/
module.exports = {
attributes:{
nickname: {type: 'string', required: true, unique: true},
className: {type: 'string', required: true},
team: {type: 'string', required: true},
rank: {type: 'string'},
},
};