0

I have rails app in that I have namespaced all modules required. The modules are not loading and getting Name error Uninitialised constant Udp

/app/adapters/Udp/     #Here Udp is the module name

contains two files.

first.rb

module Udp
  class First        #First is the class name
    def self.first_ac
        "first"
    end
  end
end

sec.rb

module Udp
  class Sec
    def self.sec_ac
        "sec"
    end
  end
end

config/application.rb

config.autoload_paths += Dir["#{config.root}/app/adapters/**/*"]

I am trying to access: Articles_controller

def index
  msg = Article.invite
  render text: msg
end

Article.rb

def self.invite
    msg = Udp::First.first_ac
    msg
end 

Please help me solving it.

rmn.nish
  • 871
  • 2
  • 8
  • 24
  • It's not just because your folder is Udb (note the b at the end) and your module is Udp (note the p at the end) is it? Or was that a typo in the question? – Shadwell Feb 15 '16 at 14:36
  • I am sorry. It is a typing mistake. I have edited it now. – rmn.nish Feb 15 '16 at 14:40

1 Answers1

0

I solved it by editing /config/environments/development.rb as below

config.eager_load = true
rmn.nish
  • 871
  • 2
  • 8
  • 24