There is no way to prevent ransomware attacks and no silver bullet for defending against them. However, following these ransomware best practices will help you minimize the risk of ransomware infections and limit the damage that a successful attack could do.
For the basics about what ransomware is and how it works, see the background information at the end of this document.