E. Cobham Brewer 18101897. Dictionary of Phrase and Fable. 1898.
To forsake a losing side for the stronger party. It is said that rats forsake ships not weatherproof. A rat is one who rats or deserts his party. Hence workmen who work during a strike are called rats.