由于最新的 Rails 3 版本不再从 lib 中自动加载模块和类,那么加载它们的最佳方式是什么?
来自 github:
A few changes were done in this commit: Do not autoload code in *lib* for applications (now you need to explicitly require them). This makes an application behave closer to an engine (code in lib is still autoloaded for plugins);
A few changes were done in this commit: Do not autoload code in *lib* for applications (now you need to
explicitly require them). This makes an application behave closer to an engine (code in lib is still autoloaded for plugins);
从 Rails 2.3.9开始,config/application.rb您可以在其中指定包含要自动加载的文件的目录。
config/application.rb
来自 application.rb:
# Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras)