Chapter 5. Extending Views

So far, you’ve experienced amazing power in a short time. Rails Active Record has let you build surprisingly capable models with no more than a handful of lines of code. Scaffolding used the metaprogramming capabilities of Ruby in concert with the metadata in Active Record to instantly slap a web face on our database tables. The Rails generators and glue code kept the structure consistent and provided the necessary tools to develop and debug the application at every step of the way. Now that we have scaffolding in place for our database tables, its time to start replacing that scaffolding interface with a prettier interface—one that lets us manipulate the relationships between our tables.

This will happen faster than you might think; now the fun really begins, as our web application’s user interface rapidly take shape. In this chapter, you will see how to:

  • Take control of the views rendered through scaffolding

  • Handle relationships in our views

  • Manage layouts

  • Make a simple change to Rails routing

  • Manage styles

The Big Picture

Let’s step back for a moment to examine the processing steps that occur from the time the server receives a URL request to when Rails finally returns the resulting HTML response (affectionately know as the big picture):

  1. The web server receives a request from the browser. A request consists mostly of a URL and some optional parameters (which may or may not be part of the URL).

  2. The web server is normally configured to serve static resources ...

Get Ruby on Rails: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.