You are previewing The Rails™ 3 Way, Second Edition.

The Rails™ 3 Way, Second Edition

Cover of The Rails™ 3 Way, Second Edition by Obie Fernandez Published by Addison-Wesley Professional

Chapter 4. Working with Controllers

Remove all business logic from your controllers and put it in the model. (My) instructions are precise, but following them requires intuition and subtle reasoning.

—Nick Kallen

Like any computer program, your Rails application involves the flow of control from one part of your code to another. The flow of program control gets pretty complex with Rails applications. There are many bits and pieces in the framework, many of which execute each other. And part of the framework’s job is to figure out, on the fly, what your application files are called and what’s in them, which of course varies from one application to another.

The heart of it all, though, is pretty easy to identify: It’s the controller. When someone ...

The best content for your career. Discover unlimited learning on demand for around $1/day.