
Model-View-Controller (MVC) is a design pattern used in software engineering, especialy in professional web development.
In applications that displays lots of data to the user, it is useful for developer to separate data (Model) and user interface (View) concerns. As the result any changes made in user interface do not impact the data handling, and also the data can be reorganized without changing the user interface.
The MVC design pattern provides that solution by decoupling data access and business logic from data presentation and user interaction. It is done by bringing intermediate component: the Controller.
MVC in Ruby on Rails
- Controllers are responsible for processing user requests, sessions, cookies, data submissions etc. They order specific data form models, which is used by view to present data to user.
- Models are Ruby classes. They interact with database, validate and store data, perform the business logic. Every functions that process data should be implemented within models.
- Views build user interface by using HTML, CSS, XML, Javascript, JSON. Content to display is passed from controllers, dependently on user’s action.