ruby on rails - Class and Module with the same name - how to choose one or another? -
i have encountered following situation:
there
modulea::moduleb::classc.do_something
in definition of do_something need use model application
def do_something ... data = order.all ... end
but there exists module
modulea::order
so error
undefined method `all' modulea::order:module
i found solution doing
def do_something ... data = kernel.const_get('order').all ... end
that returns model. question is: what's best way it? there cleaner solution? (despite fact, having same name class , module it's not greatest idea, cannot changed here...)
prefix class name ::
in do_something
method...
def do_something ... data = ::order.all ... end
Comments
Post a Comment