Templates have access to instance variables which have been set in the Ruby code block before the template is rendered. This allows data collection and organization to be kept separate from the presentation of the data.
- [Instructor] In this movie, we're going…to learn about template variables and how we can…use them to populate our templates with dynamic data.…In Ruby, there are several different types of variables,…and they differ mostly in the scope of the variable,…that is, where it's available inside our code.…The two most common types of variables…that you're going to use are local variables…and instance variables.…And we can tell the difference between them…because an instance variable begins with an @ symbol.…Always has to begin with the @ symbol,…that's what defines it as being an instance variable.…
They both work exactly the same way,…it's just that the difference in availability…of these variables inside our code.…Let me give you an example.…Here I have a route and inside the code block…you can see that I'm setting the current year…to the instance variable @ year.…And we know it's an instance variable…because it has the @ symbol in front of it.…Right below that you can see I have a local variable.…That's template.…
- Installing Sinatra
- Launching the server
- Defining routes
- Using route patterns and parameters
- Redirecting requests
- Rendering dynamic templates
- Using partial templates and layouts
- Defining custom helpers
Skill Level Intermediate
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
3. Helpers and Filters
4. Useful Techniques
- 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.