From the course: Ruby on Rails 6 Essential Training

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Create links to other webpages

Create links to other webpages - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

Create links to other webpages

- [Narrator] We've seen how a single web page works. And to see those pages we've been typing the URLs into the browser. In this movie, we'll learn to create links between pages. This is a basic HTML link. The text is "Click me" and the link target is "/demo/index". This is a perfectly valid link to use in Ruby on Rails. The important part is that link target. It just has to be a text string that matches one of our routes. When this link is clicked, the browser will then send a request using that string to the web server. And the request will be parched by the routes and then sent to the correct controller in action. While simple HTML links work, they're uncommon to see in Rails applications. The reason is because there's a helper method that helps to make link creation easier, link_to. It will be especially useful when links don't just have static text in them, but need to be more complex. The first argument to link_to…

Contents