Scope controller below a parent one

There are different ways to nest controllers, depending whether the route, the controller or both should be nested.

Nest only controller

In routes.rb:

scope module: :cats do
  resources :friends
end

Nest only routes

scope :cats do
  resources :friends
end

Nest both controller and routes

scope :cats, module: :cats do
  resources :friends
end

Namespace

A namespace nests both controller and routes. However, it also includes the namespace in the URL helpers.

namespace :cats do
  resources :friends
end