From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Defining and reading URL parameters - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Defining and reading URL parameters
- [Instructor] In the previous movie, we learned to create links and to specify the two most important parts for the URL, the controller, and the action. but what if we want to send other parameters in the URL string? Perhaps we're browsing a multipage list and we only want to view page five. In this movie we'll learn how to work with these parameters in Rails. You'll recall that an HTML, the URL parameters are the portion of the URL to the right of the question mark. In this example, page equals three and name equals Kevin. There's an equal sign between each of the parameters, name and value, and there are ampersands in between each pair. If you use the link_to method and pass in a hash values to create your link, then you can just list the parameters inside the hash. This makes managing a complex list of parameters much easier. Rails will take care of turning that hash into a URL string. When the link is clicked…
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)
-
-
-
-
-