How should you predict the battery size required for a project? I am using an Arduino nano along with an ESP8266.  The nano is connected to an OLED display and a keypad. The ESP8266 uploads the data entered from the keypad onto a server. I wish to make the device portable; i.e. add a battery to it so that it can last for at least 8 hours.  

How can I calculate the rating for the LiPo battery to use? I understand that it is very important to know the current rating of the devices in use.  

How can I make an approximate guess?
Yes, you need to know the average current draw over the period of an hour (or over a period that you then extrapolate to an hour).  That is the mAh (milliamps per hour) that your circuit draws.

It can be hard to calculate the actual current, though, since it is always changing depending on what is actually happening in your system at the time.  So I would suggest picking up a cheap current monitoring USB dongle from eBay / Amazon / Wherever (one with an LCD screen that gives mAh, such as this one and use that to get the total mAh of your system over an hour.

Multiply that mAh by 8 (the number of hours you want it to run for), and that will give you the minimum mAh for your battery. And then add some more as a safety margin, since the capacity of a battery is subject to many things (like temperature, age, etc), and the rated value is only a rough guide.

For instance, if you find your circuit uses on average 387mAh, then a battery of 3600mAh should be adequate.