There are two classes in Rails application: one with namespace, other - without. Both have the same name.
How to call a class without namespace from within a namespace?
class MyClass < ActiveRecord::Base
end
module MyNamespace
class MyClass < Base
end
class OtherClass < Base
def some_method
#Intend to create MyClass model, but MyNamespace::MyClass is created
mobj = MyClass
end
end
end
To break out of the current namespace, just write:
mobj = ::MyClass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With