...

/

A Bit More on Dispatching Requests

A Bit More on Dispatching Requests

Learn about REST requests in detail.

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:

Press + to interact
Depot::Application.routes.draw do
resources :products do
get :who_bought, on: :member
end
end

That syntax is straightforward. It says “We want to add a new action named who_bought in line 3 ...