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

Defining and reading URL parameters - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

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…

Contents