There are different ways to nest controllers, depending whether the route, the controller or both should be nested.
Nest only controller
In routes.rb
:
- Controller:
Cats::FriendsController
- Routes:
/friends
- Index URL helper:
friends_path
Nest only routes
- Controller:
FriendsController
- Routes:
/cats/friends
- Index URL helper:
friends_path
Nest both controller and routes
- Controller:
Cats::FriendsController
- Routes:
/cats/friends
- Index URL helper:
friends_path
Namespace
A namespace
nests both controller and routes. However, it also includes the namespace in the URL helpers.
- Controller:
Cats::FriendsController
- Routes:
/cats/friends
- Index URL helper:
cats_friends_path