Rails lets me nest my controllers in modules, so I can happily write:
class MyModule::MyController < ApplicationController
…in a file in /app/controllers/my_module/my_controller.rb, and Rails
will load it nicely at http://myapp/my_module/mycontroller.
However, it looks like the dependency mechanism will only work
properly if the MyModule module has not already been defined (by, say,
a plugin). I can understand why Rails might be trying to create the
module for me, so that I wouldn’t have to have code like:
…somewhere in my application such that I could then define classes
(controllers) within that module. However, I don’t see why Rails
should insist that the module doesn’t already exist if I want to put
some controllers in it.
Can anyone comment? Is this a bug, or is this behaviour necessary?
The specific error is:
Cannot load module MyModule: Object::MyModule is set to MyModule