Diarrhea can be caused by feeding an unbalanced diet, such as too many fresh fruits and vegetables, or as a side effect of some drugs, or even a gastro-intestinal bacterial infection such as pinworms or other parasites. So you should consult a vet about this if it is not something simple like feeding too much lettuce.

Make sure your rat is getting plenty of water (dehydration can happen very quickly with diarrhea). Feed a plain, bland diet such as rodent block, baby foods, or rice while the diarrhea is a problem. Check your rat and make sure it is not going into shock. Check your rat's skin elasticity-- if the skin over its shoulders feels stiff and doesn't slip back in place easily and your rat seems very lethargic and unresponsive, your rat will need immediate medical attention.

These links will take you to our rat-friendly vet lists, sorted by state:
<https://www.rmca.org/Resources/vets.htm>
<http://www.ratfanclub.org/vetref.html>