Question: are rats attracted to coffee?
Answer: Used coffee grounds are unlikely to repel rats, but rats don't want to eat them, and they get the compost cooking quickly. If you've got rats or other critters visiting your compost, adding hefty doses of chili pepper flakes, also available in bulk, will usually get them moving elsewhere.