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.

Using resourceful URL helpers

Using resourceful URL helpers - Ruby on Rails Tutorial

From the course: Ruby on Rails 6 Essential Training

Start my 1-month free trial

Using resourceful URL helpers

- [Instructor] If we use resourceful routes in our Rails projects, then all of the links and forms will need to use URLs that match those routes. Rails provides helper methods to make this process easier. You can write all of the URLs out the long way that we've seen before using a hash, you can specify the controller, the action, and the ID. But Rails takes advantage of the structure that we just saw, working with resourceful routes, and applies it to a series of helpers that make this process easier. For example, this same route can be written very simply as subject_path, and then the ID that we want to pass in. Subject path is not the only helper, there are several and each one of the helper methods corresponds to one of our crud actions. It may be daunting to just see a long list of them, but it makes a lot more sense when you understand the structure of how they are organized. First, notice that subjects path is the…

Contents