The Request Cycle
How does typing in a URL result in a web page being rendered? Here's a rough overview.
- The user types in a URL, hoping for a cool website.
- After the DNS gets resolved (a topic for another day), the request hits a web server, which asks Rails what it's got.
- Rails goes to the routes file first, which takes the URL and calls a corresponding controller action.
- The controller goes and gets whatever stuff it needs from the database using the relevant model.
- With the data the controller got from the model, it uses the view to make some HTML.
- Rails packages up the response and gives it to the web server.
- The web server delivers the response to the browser to display a cool website to the user.