MVC == “Model, View, Controller”. It’s a software development pattern that can be applied to GUI software, web applications, and other pursuits.
Rails is strongly based on MVC. The pages listed at the bottom give a Rails-centric view of the three entities, but this page covers the terms generally.
The model is where the “business logic” takes place. It defines the important “domain objects” like user, product, etc., and the relationships between them, and the processing that takes place. It’s the heart of the system.
The view is the way in which the system interacts with users. In web applications, this means generating HTML, Javascript, and perhaps images and Flash. It’s the skin of the system.
The controller ties the model and the view together. In a web application, the controller receives the user’s request, interacts with the model to process and/or receive data, and makes the data available to the view. It’s the nervous system of the application.
The view and model should theoretically know nothing about each other. The controller knows enough about both to tie them together. You should be able to take the model and apply a different view and controller and produce a different interface to the same system (e.g. GUI, web service, command-line).
Rails does not enforce strict separation of concerns (probably no framework truly does), but its mechanics are truly MVC.
category: Understanding