002 RC Model View Controller (MVC)




Rails Coach show

Summary: This is a brief explanation of how Rails implements the MVC design pattern to create such an awesome framework for building websites. In a nutshell, when a request comes to a Ruby on Rails website, it's handed the dispatcher. The dispatcher consults the routes provided in the application to determine which Controller and action to pass the request to. A Controller is a class which has methods called actions on it. The request is handled by a particular action on a controller. The Controller may then respond by gathering data from the database through the Models. I can then convert the Models' data into text or pass it to a template called a View to return the response. Most HTML responses (web pages) are returned by rendering Model data in a View. Download this Episode