I want to group my controllers into subdirectories as a matter of
internal organization, but I do not want to have these subdirectories
automatically interpreted as some latent desire on my part to create
additional namespaces. Ideally, these "nested" controllers should
continue to behave as if they were right at the root of my controllers
directory without any extra prefixes attached to any URLs.
For example:
app/controllers/subdir1/foo_controller.rb
should be accessible via
/foo/index
NOT
/subdir1/foo/index
I understand why namespaces are a very useful feature in many
situations, mine simply doesn't happen to be one of them. Is there any
way to shut this off, or at least specify a default namespace in a
generic catch-all style route?
Yes, I have read that several times. To quote the relevant section
regarding the :shallow option
"paths for nested resources which reference a specific member (that
is, those with an :id parameter) will not use the parent path prefix
or name prefix."
That's unfortunately not very "DRY" and I'd rather not clutter up the
dispatch table with dozens of nigh identical routes. It runs slowly
enough as it is.
Pros: This way you can define controllers normally, outside a Subdir
module, and they'll act as normal.
Cons: You'll have to add things to your load path manually.
That was actually the first thing I tried and it has absolutely no
effect. The problem is not that the controllers fail to load, it's
that the dispatcher interprets all path separators in their names as
nested module definitions whether you like it or not.