Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locomotive#invokable doesnt resolve controller #148

Open
ghost opened this issue Apr 12, 2014 · 3 comments
Open

Locomotive#invokable doesnt resolve controller #148

ghost opened this issue Apr 12, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented Apr 12, 2014

I have problems with invoke method. It doesnt see my controllers.

in my initializers/90_last.js i want to invoke 404 page if there is nothing found, but it doesnt resolve controllers.

Here is what i have:
app/controllers/pagesController.js

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

    var pagesController = new Controller();
    ....
    pagesController.error404 = function() {
        this.render();
    };
    module.exports = pagesController;

config/environments/all.js

var util = require('util'),
    locomotive = require('locomotive');

module.exports = function() {
    ...
    this.use(locomotive.invokable());
};

and in my config/initializers/90_last.js

module.exports = function() {

        this.use(function(req, res, next) {

                req.invoke("pages", "error404", next);
        });
};

The error that i get:

DispatchError: Unable to resolve controller 'pages'
    at Application._controller (/usr/lib/node_modules/locomotive/lib/application.js:270:17)

Versions:
LocomotiveJS: v0.4.2
NodeJS: v0.10.22

@wenq1
Copy link

wenq1 commented Apr 17, 2014

Same issue here...

@kildem
Copy link

kildem commented Apr 17, 2014

https://github.com/jaredhanson/locomotive/wiki/Migrating-from-0.3.x-to-0.4.x
with v. v0.4.0 I use (config/environments/all.js):

this.use(function(req, res, next) {
   req.invoke('pages#error404');
});

and it works fine. Is there some bug on v.0.4.2? I didn't update my version yet.

@wenq1
Copy link

wenq1 commented Apr 20, 2014

with v0.4.0 there's the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants