Whilst in high amounts this is true (and also true for humans!) the levels that a rat is likely to eat by choice are perfectly safe. Aim for no more than one garlic clove per rat and a teaspoon of chopped raw onion, more can be fed of cooked variants.