From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

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

Resourceful routes

Resourceful routes - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Resourceful routes

REST still lets us use the basic CRUD actions that we've already put in our controller, but the URLs which we use to access them will be different. These are called Resourceful Routes. Because they're closely aligned with REST, you'll also sometimes hear them called RESTful routes. We could continue to simply write match routes and use the principles of REST, and at the moment, in Rails 5, you can even use the default route structure, though that may go away later. So why use resourceful routes then? Well, first of all, it is the Rails default, and they are optimized for REST. They really make it easy to work with REST and to follow the principles of REST. And they give us a simple, consistent, and organized structure to our URLs and to our code. They also improve our application security. That's because we're able to very carefully regulate which operations are allowed on particular resources. And last of all, most professional Rails developers use resourceful routes. And if that's…

Contents