Learn to add Ruby code to a template. Ruby code must be inside ERB tags. Simple ERB tags evaluate the code, by adding an equals sign the ERB tag will also output the return value of the code. ERB tags around loops or conditional statements can be mixed wi
- [Instructor] In the previous movie we learned…how to render templates.…Now I want to talk a bit more about…how you can add code into those templates.…In the last movie, we also got a quick glimpse at ERB tags.…Let's just review those for a moment.…So an ERB tag is less than and the percent sign,…and then percent and the greater than sign.…Everything between those is considered Ruby code,…and when it goes through ERB, it's going to be evaluated.…So in the first example here, the variable year…will be set to the current year.…If those ERB tags also have an equal sign at the beginning,…then not only will that be evaluated,…but it will then be output as well.…
So it will be turned into a string,…and actually added into the template.…You're going to get very used to using both these kinds…of ERB tags.…So it'll become second nature very fast.…And then I wanted to give you a third example here…to show you how you can drop in and out of ERB.…You can see that I have a loop…which is everything from that first line…where it says each, all the way down to end.…
- 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
Ruby on Rails: Get More From ActiveRecordwith Kevin Skoglund4h 27m Intermediate
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.