There is, frankly, a darn lot of information out there regarding rat nutrition. I'm no expert, and this page is not the be-all and end-all of rat nutrition, but rather a good solid page on the basics.
Rats, like people, are omnivores, which means that they eat both animal and plant foods. Their nutritional needs are somewhat similar to people's too-- more similar than they are to those of cats and dogs. However, please do not just feed your rats whatever you are eating. Rats still need specially tailored diets to meet their dietary needs.
So what is the best diet for a rat? The truth is, nobody really knows for sure. There are differing schools of thought on the subject. As with everything, you need to research the subject, talk with your vet, and come to your own conclusions. This page is meant to provide you with information and resources to help you in this endeavor.
Like humans, rats tend to enjoy yummy junk food, but fresh and wholesome foods are what they need. A rat's diet should consist of roughly 80% staple (specially formulated rat food) foods and roughly 20% fresh fruits and vegetables.
Pregnant, nursing, and young rats need more fat and protein--but, as always, watch for protein sensitivity, and do not overfeed!
Elderly and sick rats have their own set of needs. Both need diets packed with extra nutrition. They also often benefit from being fed soft, easy to eat foods so they don't have to expend as much energy eating. In some cases, it is also physically difficult for a rat to eat harder foods that require enough strength, healthy teeth, and coordination to eat. Rats with respiratory ailments in particular are susceptible to rapid weight loss as it is more difficult for them to eat when they can't breath well.
A low sodium diet can be beneficial to rats with some health problems, particularly heart failure. For a low sodium diet, avoid all canned foods. Check the labels on all packaged foods and avoid those that have salt listed as an ingredient. Also avoid dairy, baked goods, and processed foods.
In addition to a good diet, don't forget about fresh water! Rats should always have plenty of clean water available. Every day rinse the bottle out and refill it. Once a week wash it well-- don't forget to wash all the parts. In our house we like Edstrom's Water Buddy bottles. They're more expensive than your average water bottle, but they're worth it. We love them because they're high quality, they don't leak (really!) and they can be filled from the top.
Harlan Teklad offers a good line of blocks that have wheat as the first ingredient. They offer several varieties, which mainly vary in terms of protein content. Pregnant, nursing, young, or ill rats need more protein while adult and overweight rats need less.
Harlan blocks are harder to get than regular pet store blocks. Several rescue organizations and other rat product stores online offer them, but shipping can be prohibitive.
Something to keep in mind when considering buying Harlan products is that the company sells rats, as well as other animals, to labs to be tested on. Whether or not you support animal testing is a personal decision and this is important information to know when deciding whether to buy from Harlan or not.
Natura has an interesting comparison tool you can use to compare food and treats for both cats and dogs. Keep in mind that the tool is made by Innova and may be biased.