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
config.autoload_paths += %W(#{config.root}/lib #{Rails.root}/app/delayed_jobs)
to my Rails.root/config/application.rb
However, when I try to invoke Google from rails console
, an exception is thrown. The exception goes away only if I execute require 'google'
.
Why? Shouldn't my file is autoloaded and shouldn't I access the module without any extra require
statement?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…