title: Cannot read property 'substring' of undefined
body: <p>I have the following code that is causing me an error stating Cannot read property 'substring' of undefined</p>
  
  <pre><code>      &lt;div class="extra"&gt;
          &lt;p&gt;&lt;%- blog.body.substring(0, 120) %&gt; ... &lt;/p&gt;
          &lt;a href="/blogs/&lt;%= blog._id %&gt;"&gt;Read More&lt;/a&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>However the error is occuring on my index.js page only when new content is added to the page, not on the existing content. I am using express on the backend. The change that I have made was </p>
  
  <pre><code>router.post("/blogs", isLoggedIn, function(req, res){
      // create blog
      req.body.blog.body = req.sanitize(req.body.blog.body);
      Blog.create(req.body.blog, function(err, newBlog){
          if(err){
              res.render("blogs/new");
          } else {
              //then, redirect to the index
              res.redirect("/blogs");
          }
      });
  });
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>// CREATE ROUTE
  router.post("/blogs", isLoggedIn, function(req, res){
      var title = req.body.title;
      var image = req.body.image;
      var description =  req.body.description;
      var author = {
          id: req.user._id,
          username: req.user.username
      }
      var blogPost = {title: title, image: image, description: description, author: author}
      req.body.blog.body = req.sanitize(req.body.blog.body);
      Blog.create(blogPost, function(err, newBlog){
          if(err){
              res.render("blogs/new");
          } else {
              //then, redirect to the index
              res.redirect("/blogs");
  </code></pre>