Routing Namespaces not working

152 views
Skip to first unread message

James Wyse

unread,
Jun 28, 2012, 3:36:17 AM6/28/12
to locomo...@googlegroups.com
I'm trying to set up an Admin namespace but it doesn't seem to be working. I'm using the syntax from the documentation but perhaps I've messed up the syntax.

I get an express error:
Express
500 RouterError: No controller for Admin::UsersController#index
at Locomotive. (/Users/james/Sites/sops-loco/node_modules/locomotive/lib/locomotive/router.js:420:19)
at callbacks (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/lib/router/index.js:272:11)
at param (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/lib/router/index.js:246:11)
at pass (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/lib/router/index.js:253:5)
at Router._dispatch (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/lib/router/index.js:280:4)
at Object.handle (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/lib/router/index.js:45:10)
at next (/Users/james/Sites/sops-loco/node_modules/locomotive/node_modules/express/node_modules/connect/lib/http.js:204:15)
at Object.oncomplete (/Users/james/Sites/sops-loco/node_modules/express/node_modules/connect/lib/middleware/static.js:159:11)


config/routes.js
module.exports = function routes() {
    this.root('test#index');
    this.namespace('admin', function() {
        this.resources('users');
    });
};

 app/controllers/admin/users_controller.js

var locomotive = require('locomotive'),
    Controller = locomotive.Controller;

var UsersController = new Controller();

UsersController.index = function() {
    this.title = "Users";
    this.render();
};

module.exports = UsersController;


I've tried my controller without the namespace and it works fine. Any help appreciated, cheers! 

James Wyse

unread,
Jun 28, 2012, 11:33:27 AM6/28/12
to locomo...@googlegroups.com
Okay it seems this error appears if there is an error in ANY of your controllers. In another controller I had a require statement with a typo in the path, took me a while to find that!
Reply all
Reply to author
Forward
0 new messages