Blithe Rocher

Not your average developer.

  1. About
  2. Blog
  3. Résumé

Model-view-controller (MVC)

I wanted to review the MVC concept so I took a look back at Michael Hartl's Ruby on Rails Tutorial, specifically chapter 1.2.6. I particularly like the text and the picture for conveying the information. Reposting here for future reference.

When interacting with a Rails application, a browser sends a request, which is received by a web server and passed on to a Rails controller, which is in charge of what to do next. In some cases, the controller will immediately render a view, which is a template that gets converted to HTML and sent back to the browser. More commonly for dynamic sites, the controller interacts with a model, which is a Ruby object that represents an element of the site (such as a user) and is in charge of communicating with the database. After invoking the model, the controller then renders the view and returns the complete web page to the browser as HTML.

image

Section 2.2.2 is also helpful at showing MVC in action and how the information is passed between the browser, database, model, view, and controller.