Folks new to Rails (and Ruby) often assume these declarations are a magical aspect of Rails. In fact, there is no magic—it’s just Ruby code. Indeed, Ruby makes programming in this declarative style easier than you might think.

In this short video tutorial we recreate a simplified version of the has_many declaration from scratch so you understand how to apply this same powerful technique in your own Ruby code!

Thanks for watching and please feel free to leave a comment below!

P.S. If you’re using Rails and it feels too magical or you struggle with Ruby concepts, check out our online Ruby course. You can start this course for free today and begin learning how to design object-oriented programs the Ruby way.

The Pragmatic Studio is where developers have come since 2005 to learn, practice, and improve their craft. In our acclaimed courses, you get the most up-to-date and approachable developer training around!
Learn more…