CSC/ECE 517 Fall 2011/ch4 4e ar: Difference between revisions
(→Model) |
(→View) |
||
Line 10: | Line 10: | ||
'''Definition''': A controller accepts input from the user and instructs the rest of the framework to respond to it. | '''Definition''': A controller accepts input from the user and instructs the rest of the framework to respond to it. | ||
Typically, the user input is modeled as an event and the controller converts it to a user action, understandable by the model. Based on the input, it also decides which views to render. The controller is also responsible for a number of auxiliary services like session management, caching and helper modules. Code for a controller can be found in the ''app/controllers/'' of a rails project. | Typically, the user input is modeled as an event and the controller converts it to a user action, understandable by the model. Based on the input, it also decides which views to render. The controller is also responsible for a number of auxiliary services like session management, caching and helper modules. Code for a controller can be found in the ''app/controllers/'' directory of a rails project. | ||
===Controller=== | ===Controller=== |
Revision as of 00:07, 19 October 2011
Lecture 10
Model, View and Controller
Model
Definition: The model represents all the data in the application.
A model is typically mapped to a table in the database. It maintains the state of an application and responds to changes to alter it. The model provides the developer with a consistent interface to handle and manipulate the data in an application. It hides a object-relation-mapping underneath, allowing the application to be portable to various database management systems. The model also validates the data before storing it. The code for a model can be found in the apps/models directory of a rails project.
View
Definition: A controller accepts input from the user and instructs the rest of the framework to respond to it.
Typically, the user input is modeled as an event and the controller converts it to a user action, understandable by the model. Based on the input, it also decides which views to render. The controller is also responsible for a number of auxiliary services like session management, caching and helper modules. Code for a controller can be found in the app/controllers/ directory of a rails project.
Controller
Definition: