Adding lib to 'config.autoload_paths' in Rails 3 does not autoload my module

后端 未结 6 1992
抹茶落季
抹茶落季 2020-11-28 02:52

I place a file name g.rb in side Rails.root/lib folder The file content is like this:

module Google
end

Then I add

         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 03:40

    I faced the same problem just now, and my "solution" (or rather workaround) was to manually require every needed file from Rails.root/lib in my application.rb.

    require 'lib/message'
    require 'lib/store'
    require 'lib/vault/vault.rb'
    require 'lib/custom_loggers'
    
    module MyApplication
      class Application < Rails::Application
    

    My next step would be to categorize the files in module folders as you mention.

提交回复
热议问题