These are chat archives for quorrajs/quorrajs

3rd
Dec 2016
n3wcr4zy
@n3wcr4zy
Dec 03 2016 00:32
how i access flash data in jade?
Harish
@harishanchu
Dec 03 2016 06:44

flash data is accessed with following method:

let value = req.session.get('key');

If you flash form input values you can access it with following method as well:

let value = req.input.old('key');

If you want to call any method on req.session you have to expose req.session to your view by passing it as a view option.

Or you can assign req.session to res.locals object as well to get access from views:

For example from your route if you do the following:

res.locals.session = req.session

now you can access all session methods from your view like:

p Welcome #{session.get('name')}
@n3wcr4zy
n3wcr4zy
@n3wcr4zy
Dec 03 2016 11:43
@harishanchu Thanks! and thanks for the framework is great!!!
Harish
@harishanchu
Dec 03 2016 11:45
@n3wcr4zy you are welcome :)
n3wcr4zy
@n3wcr4zy
Dec 03 2016 13:28

I'm getting this error:

[Error (E_UNKNOWN) Encountered an unexpected error] Details: Error: No find() method defined in adapter!

in my index action:

this.getIndex = function(req, res) {

        var users;
        var fn = function (err, data) {
            if (err) throw err;
            users = data;
        }

        User.find(fn);

        res.view('index', {
            title: 'Your Movie House',
            users: users
        });

    };

what's wrong?

n3wcr4zy
@n3wcr4zy
Dec 03 2016 13:41
Oh, i forgot to change the 'connection' attr to 'mysql'. the default is localDisk. thats why.
Harish
@harishanchu
Dec 03 2016 14:25
@n3wcr4zy Even if you make that right, you wont get users displayed properly with that code. User.find method is asynchronous, hence you might want to to call res.view method from the fn callback method.
n3wcr4zy
@n3wcr4zy
Dec 03 2016 14:30
@harishanchu yeah, I already fixed that
Harish
@harishanchu
Dec 03 2016 14:32
Okay
This message was deleted