Search⌘ K
AI Features

A Bit More on Dispatching Requests

Explore how Rails extends resource routing through additional actions, nested routes, and routing concerns. Understand shallow nesting to simplify URLs and how to manage multiple response formats like HTML, JSON, and XML. This lesson helps you configure and optimize request dispatching within a Rails application.

Adding additional actions

Rails resources provide us with an initial set of actions, but we needn’t stop there. In Atom Feeds, we added an interface to allow people to fetch a list of who bought any given product. To do that with Rails, we use an extension to the resources call:

Ruby
Depot::Application.routes.draw do
resources :products do
get :who_bought, on: :member
end
end
...
Ask