I really think someone pulled your leg there. Peanut butter is a great bait, but also perfect food. If you mix it with plaster of paris, that's a different thing.
Just did a search for onions, well, yes, they are toxic to rats, but I highly doubt a wild rat would eat enough even when mixed with peanut butter, it's not easy to poison a wild rat fast enough before it wiped out some more rabbits - but that sure is worth a try, dosn't cost much.
https://kidadl.com/fun-facts/do-onions-kill-rats-best-ways-to-get-rid-of-a-rat-naturally
Still, set good quality snap traps.
Playing around with diy improvised live traps can be done, but I wouldn't relay on it.