title: Passing an object to views/layout.ejs in sails.js
body: <p>I am having a hard time trying to pass an object to the layout of my project in order to get a list of categories i need to show in the navbar. I have been trying o couple of solutions here and all relates on using a policy and assigning res.locals.myVar = someObj, the problem is that res.locals and also using req.options.locals.myVar are only available in the controller action's view and not the layout</p>
  
  <p>So far i got this.</p>
  
  <p>// getRoomList POLICY </p>
  
  <pre><code>Room.find().exec(function(err, rooms) {
      if (err) {
          return res.badRequest('Something went wrong.');
      }
      if (rooms) {
          res.locals.roomlist = rooms;
          next();
      } else {
          res.notFound();
      }
  });
  </code></pre>
  
  <p>// config/policies</p>
  
  <pre><code>'*': 'getRoomList'
  </code></pre>
  
  <p>// In layout.ejs</p>
  
  <pre><code>&lt;%= roomlist %&gt;
  </code></pre>