Sails version: 0.12.13
Node version: 7.7.1
NPM version: 4.1.2
Operating system: alpine:3.4
I generated a new API using command sails generate api microController, it has created model and controller files as expected and RESTful blueprints are working perfectly.
But when I want to add a new custom route:
'/microcontroller/:id/check': 'MicroControllerController.check'
I have the following error message in my console:
error: Ignored attempt to bind route (/microcontroller/:id/check) to unknown controller :: micro.
It happens because the controllerId is normalized two times using sailsUtil.normalizeControllerId(). Once before the call to bindController()
here and a second time inside the function here.
I added a debug console log into sailsUtil.normalizeControllerId() which produce the output:
debug: normalize controller id: MicroControllerController
debug: normalize controller id: microcontroller
I would enjoy to PR something but I don't understand why two calls to sailsUtil.normalizeControllerId() are needed.
Hi @MelwinKfr. Yeah, this has to do with the fact that controller names are required to have Controller at the end, but that string is stripped off when determining the controller identity to be used internally. I'd have to look into if/why the two calls are needed, but in any case this is unlikely to be fixed in the 0.12.x branch, so in the meantime you should be able to work around this by using an alternate route syntax:
'/microcontroller/:id/check': {controller: 'MicroControllerController', action: 'check'}
Another reason for this problem that you may have written the name of the Controller wrong in the routes.js file ...
馃帀 Closing now that v1.0 is officially released.