我正在嘗試使用myapplication/somefolder
下的文件。谷歌和#1說我應該補充一點:如何在Rails應用程序的根目錄下自動加載文件夾中的文件
config.autoload_paths += %W(#{config.root}/somefolder)
在我config/application.rb
,所以我做到了。
但是文件不會被加載。
我試過namig somefolder/myclass.rb
都class Myclass
和class Somefolder::Myclass
但仍然沒有運氣。
我可以看到,DIR是在控制檯Rails.application.config.autoload_paths
發現確實包括我/path/to/myapplication/somefolder
目錄,這樣應該沒問題。
圍繞此主題的所有其他問題使用theapp/app/somefolder
或theapp/lib/somefolder
但不theapp/somefolder
所以也許這就是它爛的地方。
所以我嘗試引用與::Somefolder::MyClass
類,但沒有幫助。
我用Rails 3.2.1
更多的研究表明,'的ActiveSupport :: Dependencies.autoload_paths'不包含我的'在運行時somefolder'路徑。任何想法爲什麼? – hakunin 2012-02-24 11:56:04