MΓ³dulo 06 Β· Rails Anatomy β LecciΓ³n 2 de 5 Β· ~6 min
MVC in One Picture
One request, four stops
Every request into dogpark takes the same trip, in the same order:
- Browser sends
GET /walkersto the dev server. config/routes.rbmatches the URL to a controller action βwalkers#index.- Controller action runs Ruby code, usually asking a model to fetch rows from the database.
- View takes whatever the controller loaded and renders it into HTML.
- That HTML travels back to the browser as the response.
That's MVC: Model talks to the database, View renders HTML, Controller sits in the middle and coordinates the two. Every folder from the tour maps onto one letter: app/models is M, app/views is V, app/controllers is C. config/routes.rb isn't a letter of MVC β it's the map that decides which controller action even runs.