Every neighbourhood has an underlying rat population, even if you don’t realise they are there. Rats only become a problem when they breed in numbers and invade our living spaces. If this happens they can cause substantial health and nuisance problems and will need to be controlled. However, your compost heap is unlikely to attract them to any degree, and you should never add cooked food. Placing the compost bin on a hard surface or chicken wire can help to keep rats out of a compost bin.