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 ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.