由于最新的Rails 3版本不再自动加载来自lib的模块和类,加载它们的最佳方法是什么?
来自github:
Run Code Online (Sandbox Code Playgroud)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);
怎么样require和require_dependency不同?
如何require_dependency在开发中自动重新加载类但require不能?
我深入研究了Rails ActiveSupport::Dependencies和dispatcher.rb代码.我在require_dependency代码中看到的是它基本上将常量添加到autoloaded_constants数组中.但是clear_application在每个请求之后它会在内部调度程序中被清除.
有人可以给出明确的解释或指出一些有用的资源吗?