Who Controls the Controller?

All our new tests pass, so let’s take stock. We still have one test pending—our end-to-end test still doesn’t like that the create action can’t be found in the ProjectsController. Now we have all the pieces we need to write that action.

Since we’ve put our business logic in the action object, the controller doesn’t have much logic, but it does have some. Specifically, the controller sends data to both the action object and onward to the view layer. Although we haven’t stressed the point, the controller also needs to do something in case the action object errors or does something else unexpected. Notice that we’ve separated responsibilities here—almost nothing that the controller does is dependent on the logic of ...

Get Rails 4 Test Prescriptions now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.