O'Reilly logo

Enterprise Rails by Dan Chak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Organizing with Plugins

In most Rails books, this chapter comes last. It takes a lot of complicated examples to show why you need to organize your code at all. Examples at the beginning of books are simple enough that organizational strategies aren’t necessary. By the end of a book, if you get that far, it’s often too late for this sort of wisdom to be practical. Most readers, myself included, are actively programming while reading a new book for useful tips and insights and want to get to the meat of things right from the start. Unfortunately, the result of this pattern is that many Rails projects end up poorly organized. By the time you get to the chapter on code organization, you may already have a functioning application with millions of users (I hope this is your problem).

In this book, I’m going to break with tradition and present some high-level principles of code organization before we even write any code. Because of this “backward” presentation, some of what follows may seem unnecessary, burdensome, or even purposeless. Rest assured, the ideas that follow have none of these properties. They come from three years of incremental development of a 100% pure Rails website that, as of this writing, receives approximately two million unique visitors per month.

From this experience, I can tell you honestly that at some point, the amount of code you have will begin to strangle you. You may have started with a dozen classes, but a couple years down the road you have hundreds. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required