我将一个文件名 g.rb 放在 Rails.root/lib
侧的文件夹中
文件内容如下:
module Google
end
然后我加上
config.autoload_paths += %W(#{config.root}/lib #{Rails.root}/app/delayed_jobs)
到我的 Rails.root/config/application.rb
但是,当我尝试从 rails console
调用 Google 时,会抛出一个异常。只有在执行 require 'google'
时才会消除异常。
为什么? 我的文件不应该是自动加载的,我不应该访问模块没有任何额外的 require
语句?