Is it possible to programmatically clear Rails 3 layouts and view caches?

I have a Rails 3 based CMS that allows users to create and modify layouts and views. These layouts and views are the same as those built into the structure, only reinforced by the model for some additional features. The problem that I would like to touch upon is that these template files are cached as soon as they are publicly available, so it is impossible to see changes in layouts or views if the server is not restarted. This does not happen in design mode, where caching is disabled, but obviously disabling template caching in production will not be great for performance. Clearing memcache doesn't seem like a trick. Is it possible to programmatically clear layouts and cache views in production, perhaps with something like a reboot!how are we in the console? Or I have to restart the Passenger every time someone wants to customize one of these layouts or views (perhaps using the approach in this thread:Clearing Rails caches )?

Please note that I do not mean clearing page caches and actions that public pages rely on and works fine.

+5
source share
3 answers

Jose Valim has a wonderful chapter in Rails Rails Applications that covers this topic. Here is the approach that Mongoid uses to store view templates. If you create your own View Resolver, you just need to call #clear_cache on the resolver instance when someone stores the new template in the database.

+2
source

this configuration may help (at least it worked for me):

config.action_view.cache_template_loading = false
  • 3

2:

config.action_view.cache_template_reloading = false
+2

rails, , . , , . , restart.txt -.

: tmp/restart.txt . .

+1

All Articles