ror开发的一个强势就是其解释性勿须编译,对源文件的更改可以立即体现在运行中,当启动rails应用之后,可以运行ruby script/console对应用进行即时调试,比如对model进行query测试,检验find查询的语句编写和结果查看,好处是不用打开数据库控制台就可以进行数据库编程,在检查查询的同时也校验了程序的编写,提高了开发效率。最近在开发当中遇到个问题,就是development mod下启动rails应用之后,在console中做调试时发现对源文件的修改并不能立即生效,检查config/environments/development.rb配置,config.cache_classes = false,应该是支持类的重新加载,而通过browser发出请求,修改是生效的,如何解决这个问题?当然一个办法就是需要不停的关闭和重启rails应用,但是太麻烦了,后来查了一下网上的资源,发现可以在console当中输入‘reload!’强制rails进行类重新加载,问题得到解决。
config.cache_classes配置选项的设置意义如下:
[quote]
Without getting into too much nitty-gritty detail, when the config.cache_classes setting is true, Rails will use Ruby's require statement to do its class loading, and when it is false, it will use load instead.
[/quote]
至于require与load的不同,可以查看yjjxf的一篇文章:
[url]http://www.iteye.com/topic/79864[/url]
config.cache_classes配置选项的设置意义如下:
[quote]
Without getting into too much nitty-gritty detail, when the config.cache_classes setting is true, Rails will use Ruby's require statement to do its class loading, and when it is false, it will use load instead.
[/quote]
至于require与load的不同,可以查看yjjxf的一篇文章:
[url]http://www.iteye.com/topic/79864[/url]