Sai
Sai

Reputation: 135

Namespacing issue in rails

I have a class A in module M like below

  Module M
    class A
       def method1
          # how to instantiate a model having same name as A
          #like A.first
       end
     end
  end

In my models I have a class A

 class A < ActiveRecord::Base
 end

Upvotes: 0

Views: 34

Answers (1)

Agis
Agis

Reputation: 33636

You can access the global scope using the :: operator, e.g:

 Module M
    class A
       def method1
          ::A.first
       end
     end
  end

Upvotes: 1

Related Questions