Chapter 5. Working with Views
So far, youâve taken a quick pass through Rails controllers and views in Chapter 1, where you learned how a basic Rails request works. Then, you took a deeper dive into controllers by using the scaffolding feature to build basic models, views, and controllers for your application in Chapter 2. In Chapters 3 and 4, you fleshed out the Active Record models, adding the relationships you need to make each one of them work for Photo Share.
It may not seem like it, but the lionâs share of this demo application is built. Most of the remaining work is related to views and testing. In this chapter, you will learn how to:
Take control of the views rendered through scaffolding
Handle relationships in our views through building in links
Render common pieces of a website (such as a navigation bar) through layouts
Work with Rails routes to build friendlier URLs
Reuse shared common pieces of a web page in fragments called partials
Manage CSS styles to keep your application more consistent
The Big Picture
Letâs step back for a moment to review the basic processing steps that happen from the time the server receives a URL request to when Rails finally returns the resulting HTML response (affectionately known as the big picture):
The web server receives a request consisting mostly of a URL, some optional parameters, and a message body. The web server sends the request to the Rails application for handling.
The web server will handle requests for static resources, such ...
Get Rails: Up and Running, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.