how to send a flash message with res.redirect('/') sails js-open source projects balderdashy/sails

How to send a flash message with res.redirect('/') in Sails?

When i check some condition in a controller then I want to redirect to another url, passing along a flash message.

I am new to Sails, so any help will be appreciated.

Controller action:

module.exports ={
   index: function (req, res) {

    if(req.param('key')){
      req.flash('message', 'welcome key is present');
      res.redirect('/view/');
    } else {
      req.flash('message', 'welcome key is not present');
      res.redirect('/');
    }

  }
}

Thanks in advance.