Layouts allow pages to be rendered using a common structure without having to repeat code. Pages can share the same header, footer, menu, or sidebars. In Ruby on Rails, this is done by rendering a template, containing a fragment of HTML, inside of a layout. Learn to use the default layout and to create and use a new custom layout.
- View Offline
- Exercise Files
- [Instructor] Throughout this chapter,…we'll be learning techniques…for managing view templates…and exploring Rails view helpers.…We're gonna begin by looking at layouts.…Most pages on a website…are going to share a common structure:…the header, the footer, the style sheet,…and possibly other side items,…like navigation menus or sidebars.…At the end of the last chapter,…we saw one example of this,…using the flash hash,…which we want to appear on every page…which might need to render a flash message.…It makes the most sense if we could define…those shared page elements in one place…and then reuse them.…
Remember, "don't repeat yourself"…is one of our core principles,…and that's exactly what a layouts help us to do.…Up until now, the templates we've been working with…have been html fragments, not proper html pages…with header and body tags.…That was intentional on my part…because now we'll be able to drop those fragments…into a layout.…Let's take a look at a simple Rails layout.…Here I have a basic html template,…with html head, title, and body tags,…
- Creating and configuring a new Ruby on Rails project
- Generating controllers and views
- Handling server requests
- Using different types of routes
- Rendering and viewing templates
- Generating migrations and models
- Creating, updating, and deleting records
- Finding records with queries
- Understanding relationship types
- Writing controllers for CRUD
- Working with layouts and helpers
- Managing application assets
- Building forms
- Validating data
- Authenticating users
Skill Level Beginner
MVC Frameworks for Building PHP Web Applicationswith Drew Falkman2h 39m Intermediate
Up and Running with Python and Djangowith Caleb Smith1h 11m Intermediate
RSpec Testing Framework with Rubywith Kevin Skoglund6h 13m Intermediate
1. What Is Ruby on Rails?
2. Get Started
3. Controllers, Views, and Dynamic Content
4. Databases and Migrations
5. Models and ActiveRecord
7. CRUD, REST, and Resourceful Routes
8. Controllers and CRUD
9. Layouts, Partials, and View Helpers
12. Data Validation
13. Controller Features
14. User Authentication
15. Improve the Simple CMS
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.