Controllers
Controllers map the application to a specified base route. Each controller also contains routes that extend from the base route.
CLI tasks
Example
app/controllers/product_controller.rb
The base route for the controller is specified in line
1
:Routes defined within this controller are relative to the base route (
/products
). This means that:get '/'
maps to the route/products/
get '/:id'
maps to the route/products/:id
Main controller
The main controller (MainController
) works slightly differently. Since it inherits directly from ApplicationController
, you cannot specify a base route, as the controller is always mounted at /
.
Last updated