This is part 5 of Ramaze by Example, a tutorial on web development. In Part 4: View, we coded up the front end of our application.
The Controller part of the MVC pattern is the meat of your application. As much as possible, the logic, thinking, rules, and procesess of your application should be placed in controllers. A controller acts as a hub, or a central place of command. Controllers interact with models to read the state of the system, prepare variables with data that the views display, accept interactions from the user, and use models to modify the system state stored in the database. To do things by the book, you should try to keep to a minimum the Ruby code used in your views, and instead place it in controllers. (more…)