There are a lot of people who have a lot of opinions about ORMs. This person and this other person both suggest that ORM is an anti-pattern. I can't really empathize with these people at all and I assume they cry themselves to sleep at night. Unlike them, I have things to do, which is why I'm a fan of tools like Rails to accelerate and simplify my development efforts.

99% of the time, I feel like Rails (and other ORMs) positively contribute to my code. They keep things simple, readable, and maintainable, which is a very important thing when you're onboarding new engineers. Furthermore, they provide pretty much all of the DB functionality I need at a fraction of the development effort. In the case of Rails, it's easy to build composable pieces of logic using scopes that lead to extremely expressive and elegant code.

Having said that, the one problem with ORMs is that, as developers, we almost completely stop paying attention to the SQL that's being generated. Again, 99% of the time this is totally fine and is, of course, the intention of the design pattern's abstraction. Once in a while, though, the wrong query will burn your ORM paradise to the ground. In my experience, this very frequently involves locking.

Let's say that we have a company where we sell some stuff to people, and then we have to ship that stuff to them from one of our warehouses. Here's what our models look like: