我正在测试 Sails.js 并尝试在前端连接到 Ember.js,但在 Sails 中自动生成的 Controller 方法路由方面遇到了问题。
我在 Sails.js 中生成了一个 TestModel
模型,我可以通过 http://localhost:1337/testModel
查询该模型,甚至可以更好地与Ember,我可以将 pluralize
蓝图配置选项设置为 true,使其成为 http://localhost:1337/testModels
。
但是,Ember 的命名约定会为数据存储查询方法生成类似 http://localhost:1337/test-models
的请求。
有什么方法可以自动化 Sails.js 生成脊髓大小写而不是驼峰命名法吗?或者如果没有,是否可以让 Ember 来做?
我正在尝试找到一个不包括为每个有问题的模型名称编写自定义配置的解决方案。
最佳答案
您可以通过查询 testModels
而不是 test-models
来在 Ember 数据中轻松解决这个问题
App.IndexRoute = Ember.Route.extend({
model: function() {
return this.get('store').find('testColor');
}
});
关于javascript - 是否可以更改 sails.js 蓝图生成的驼峰案例 Controller 路线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21343241/