Instance variables are used to maintain values inside Ruby classes. In Rails, they are also used to pass data from the controller to the view. The controller’s job is to set up any values that the view will need ahead of time. Any instance variable called in a template will be “bound” to the value of any instance variables set in the controller.
- View Offline
- Exercise Files
- [Narrator] In the last movie we saw how to…embed Ruby code into our templates.…In this movie we're gonna learn how to use…instance variables to give our templates access…to data gathered by the controller.…Think back to our MVC diagram for a moment.…The controller makes decisions about the flow…of the application…but it also has the role of gathering data…to be used in the response.…The controller needs to examine the quest…and then make queries of the models…and then call the view template.…The view should already have everything set up…before hand so that it can focus on it's job…which is how to present that data.…
A good way to think about it is to imagine a rock concert.…There's a guitar tech who comes out and sets up all…the guitars on stage ahead of time.…There are different guitars for different songs,…they may have different tunings.…When the guitarists comes on stage to play…all the guitarists has to do is walk over,…pick up the guitar, and play.…That's the presentation.…The guitar tech took care of everything else…
- 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.