I came across the following situation:
Exists
ModuleA::ModuleB::ClassC.do_something
in the definition of do_something I need to use the model from the application
def do_something ... data = Order.all ... end
But there is also a module
ModuleA::Order
So, I get an error message
undefined method `all' for ModuleA::Order:Module
I found a solution by doing
def do_something ... data = Kernel.const_get('Order').all ... end
This returns the model. My question is: what is the best way to do this? is there a cleaner solution? (despite the fact that the same name for the class and module is not the biggest idea, but it cannot be changed here ...)
ruby module class ruby-on-rails
santuxus
source share