Saving Data

Request/Response Cycle

So far we've built a Rails app containing a static page. To do this, we used a controller, a route, and a view. The request/response cycle summarizes how these three parts work together.

However, a Rails app with static pages looks the same for all users. How can we create apps that save information? We do this with a database. Here's how a database fits into the request-response cycle. Check out the diagram in the browser.

  1. When you type http://localhost:8000/welcome, the browser makes a request for the URL /welcome.
  2. The request hits the Rails router.
  3. The router maps the URL to a controller action to handle the request.
  4. The controller action recieves the request, and asks the model to fetch data from the database.
  5. The model returns data to the controller action.
  6. The controller action passes the data on to the view.
  7. The view renders the page as HTML.
  8. The controller sends the HTML back to the browser.
Community Forums
Get help and ask questions in the Codecademy Forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.