By default, Rails will render a template that has the same name as the action being called, and it will look for that template in a directory whose name matches the current controller name. It is also possible to specify a different, custom template to use by using the render method. Calling render does not perform a new controller action; it just sets the template to be used.
- [Narrator] In this chapter, we're going…to examine how the controllers and views work…and how they allow us to output dynamic content.…And we're going to begin by learning…how templates are rendered.…Let's review the MVC diagram.…The end of the last chapter, we saw how browser requests…are routed to the correct controller and action.…At that point, the controller takes over.…And the controller's job is to control,…control the flow through the application…and to make choices about how to respond to the request.…The controller could access our model…and our databases during this process,…but it doesn't have to.…
So let's set those aside for now…and focus on how the controller decides…which view should be used.…In the last chapter, we generated a demo controller…which also created a demo directory in our views…and added a file for our index action.…This file is called a view template.…It's a template because most of the time…it's going to have dynamic content added to it.…Let's try adding a new view template.…You can see the template that it already added for us.…
- 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
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.