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 - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Render a view template for a browser5m 35s
-
(Locked)
Redirect controller actions5m 13s
-
Define view templates using HTML5m 34s
-
(Locked)
Use instance variables to set values in the template3m 42s
-
(Locked)
Create links to other webpages4m 17s
-
(Locked)
Defining and reading URL parameters6m 38s
-
(Locked)
Challenge: Dynamic templates3m 22s
-
(Locked)
Solution: Dynamic templates6m 9s
-
(Locked)
-
-
-
-
-