I am following Sail.js tutorial from http://irlnathan.github.io/sailscasts/blog/2013/08/27/building-a-sails-application-ep4-handling-validation-errors-with-a-flash-message/<
You can add this export:
module.exports = function flash(req, res, next) {
if (!req.session.flash) {
req.session.flash = {};
req.session.flash['success'] = [];
req.session.flash['warning'] = [];
}
next();
};
and then in the view:
<% if (req.session.flash['success'].length > 0) { %>
<%= req.session.flash['success'].pop() %>
<% } %>
<% if (req.session.flash['warning'].length > 0) { %>
<%= req.session.flash['warning'].pop() %>
<% } %>
You can create messages in the controller like this:
req.session.flash['success'].push('Updated successfully');