title: Passing an array to a EJS view, using Bookshelf.JS
body: <p>My logic:</p>
  
  <pre><code>/* GET /events/list */
  router.get('/events/list', function(req, res) {
  
      new db.Tag({})
      .fetchAll()
      .then(function(tags) {
  
          res.locals.title = "List of events";
          res.locals.tags = tags;
          res.render('events/list.ejs');
      });
  });
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>&lt;% for (var tag in tags) { %&gt;
      &lt;div class="checkbox"&gt;
          &lt;label&gt;
               &lt;input type="checkbox" data-tag-id="&lt;%= tag.tagId %&gt;" /&gt;
               &lt;%= tag.name %&gt;
          &lt;/label&gt;
      &lt;/div&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>What I'm getting:</p>
  
  <pre><code> [x] undefined
   [x] undefined
   [x] undefined
   [x] undefined
  </code></pre>
  
  <p>What I should be getting:</p>
  
  <pre><code> [x] foo
   [x] bar
   [x] zort
   [x] troz
  </code></pre>
  
  <p>I also tried passing </p>
  
  <pre><code> res.locals.tags = tags.toJSON();
  </code></pre>
  
  <p>and also</p>
  
  <pre><code> res.locals.tags = JSON.stringify(tags);
  </code></pre>
  
  <p>So.. how do I finally pass my collection to an EJS view?</p>
  
  <p>I also logged (<code>console.log(tags)</code>) just after <code>then(function(tags)</code> and I'm getting the models (tags in this case) correctly.</p>
  
  <p>I also tried tags.forEach in my EJS view but a native javascript array like this: <code>[{tagId:1, name:"blah"}, {tagId:2, name"Foo"}]</code> doesn't have "forEach" method implemented</p>