I have the following code to pull out and instantiate Rails controllers:
def get_controller(route)
name = route.requirements[:controller]
return if name.nil?
This was solved by an answer from user apneadiving which can be found here
Be aware that there are vicious cases in Rails development mode. In order to gain speed, the strict minimum is loaded. Then Rails looks for classes definitions when needed.
But this sometimes fails big time example, when you have say
::User
already loaded, and then look for::Admin::User
. Rails would not look for it, it will think::User
does the trick.This can be solved using
require_dependency
statements in your code.
Personally I think this is a bug, not a feature, but...so it goes. It solves the problem.