Ruby on Rails: unloadable

守給你的承諾、 提交于 2020-01-01 07:33:31

问题


What does unloadable do?

I saw this in the pages controller of High Voltage by thoughtbot. thoughtbot blogs about unloadable, but am still unclear on what it does.


回答1:


It means that when you're running on an environment configured with cache_classes = false (like the development environment) these classes are going to be reloaded by Rails on every request, so you can place them inside your lib folder or inside a plugin and they will always be reloaded without you having to restart the app (as classes inside lib or plugins are not reloaded by rails on every request by default).

This is mostly useful when you're building a plugin and you would like to do live changes on it without having to go through the process of always restarting your app on every test.

You can see the unloadable method documentation here.



来源:https://stackoverflow.com/questions/6853471/ruby-on-rails-unloadable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!