Defining top-level scope methods in Ruby is risky
Defining methods in the top-level scope might immediately sound like a bad practice, but surprisingly, I’ve seen it appear in various Rails projects. Sometimes, this happens unintentionally, while other times, developers do it to make methods more accessible from different parts of the application. Here, I’ll explain why this approach is problematic and how it can happen without you even noticing.