I almost always have a granola bar or two in my handlebar bag ... it doesn't matter if the ride is 30 minutes around town or several hours.
If I know that the ride is going to be more than 2 hours, I'll make sure I've got something in my handlebar bag.
If the ride is going to be more than 3 hours, I'll make sure I've got approx. 1 granola bar per hour ... and I'll also be thinking about the route and whether or not there will be food available.
If the ride is going to be more than 6 hours, not only will I have approx. 1 granola bar per hour with me, I'll also have an idea where we might stop for lunch.
The general recommendation is to consume 200-300 calories per hour on rides of 2 hours or more. But when rides go over 6 hours, then it's good to consume "meals" of 500 calories or more once every 4-6 hours.