When I pass res.render object then in .ejs file it is undefined-Collection of common programming errors

I want to show values of post object in my profilearea.ejs file.But when it renders to profilearea.ejs then it gives an error that “post is not defined”.

Here is the code in node.js

PersonalInfo.findOne({username:req.body.name}, function(err,post){
    if(err || !post)
    {
        console.log("find is not done");
    }

    else
        res.render('profilearea.ejs', {post:post});

  }

})

This is the code in profilearea.ejs file


       

INFORMATION

       

        
  1. I think part of the issue may be in not stringifying the object prior to rendering.

    Try:

      else {
      var jpost = JSON.stringify(post);
      res.render('profilearea.ejs', {post:jpost});
      }
    

Originally posted 2013-11-09 22:38:34.