Locked lesson.
About this lesson
Exercise files
Download this lesson’s related exercise files.
Creating Links with Embedded Ruby vs. HTML.docx58.7 KB Creating Links with Embedded Ruby vs. HTML - Solution.docx
59.6 KB
Quick reference
Creating Links With Embedded Ruby vs. HTML
In this video we discuss creating links with embedded Ruby.
When to use
Any time you want to add a link to your app, you should use embedded Ruby instead of basic HTML.
Instructions
Embedded Ruby links look like this:
<%= link_to, "Anchor Text", link_path %>
Where "Anchor text" is the text that you want to appear in the link on the web page, and "link_path" is the route to the actual file that the link points to.
You find the link_path by running the "rake routes" command from the terminal.
Hints & tips
- Embedded Ruby links are always better than plain HTML links
- Embedded Ruby links automatically update whenever you change your app, HTML links do not
- Api.rubyonrails.org is a great reference to look up how to create links in case you forget
Lesson notes are only available for subscribers.