【发布时间】:2015-10-08 11:40:49
【问题描述】:
我在文件 api/blueprints/count.js 中创建了自定义蓝图操作计数。
我想将此操作推广到所有模型。问题是当我添加这样的自定义蓝图操作时
'get /:model/count': {blueprint: 'count'}
我在提升应用程序时收到此错误:
error: count :: Ignoring attempt to bind route (/:model/count) to blueprint action (`count`), but no valid model was specified and we couldn't guess one based on the path.
我通过在配置属性中指定模型名称来解决问题
'get /:model/count': {blueprint: 'count', model: 'user'}
或在地址中指定
'get /user/count': {blueprint: 'count'}
这样指定的问题是我还需要为每个其他模型添加路由。有什么方法可以将这条路线概括为类似 'get /:model/count': {blueprint: 'count'}。
如果我们有这个功能,那就太好了。
请帮忙。
【问题讨论】: