I use namespaces for nested resources or for separate areas of the app (like admin vs. customer)
I don’t put a top level resource in a name of its own. So, I wouldn’t have
However, if I wanted the posts for a particular topic, it would be
Topics::PostsController like this:
resources :topics do
resources :posts, controller: 'topics/posts'
Then, by convention, any controller inside the
Topics namespace is going to have a
This approach also allows me to have multiple controllers named the same thing within different namespaces, where the namespace fully describes the context.
PostsController is for all posts in the system,
Topics::PostsController is for all posts for the given topic, and
Authors::PostsController is for all posts for the given author. Note: sometimes this doesn’t play well with Rails’ autoloading, so I use
require_dependency pretty liberally.