In This Chapter
Watching the controller interact with the view
Passing information between the controller and the view
Dividing a task into several different files
The material back in Chapter 3 involves a lot of magic. When you click a Finish button, Rails creates 35 folders and 45 files. Later in the process, Rails creates Web forms and updates databases. And to get all this functionality, you write only five lines of code.
So what's the trick? What does Rails do behind your back to make all this wizardry happen?
This chapter reveals one part of the magic; namely, the interaction between a controller and its view.
Imagine that you chair a committee whose members are writing a big report. How do you divide the work? There are good ways and bad ways to assign tasks.
As committee chair, you can decide to do all the work yourself. This saves you the headache of having to delegate tasks. Committee members don't have to contact one another to coordinate their work and check the consistency of their contributions. In the end, no one has to paste parts of the report together. But writing the entire report might overwhelm you. You might have trouble keeping all the facts in your head while you juggle sections 6, 7, 10, and 20 in the huge volume of material.
Another approach is to divide the report into words. The committee has three members, so have each member write every third word. This is definitely a bad idea. If the Gettysburg address ...