Two things attract rats:
1) Food scraps - especially meat and dairy products. Never put food in your yard waste compost pile or bin – rats will chew right in. Instead use the more rodent-resistant worm bin, Green Cone or home-made food waste digester designs (call the Hotline, or see website at top.)
2) Sometimes a dry compost pile can attract rats as a nest site, especially if close to a fence or building. Keep you pile moist enough to compost, and it won’t attract them.