[typo] calling controller and caching from a sweeper class
lists at matiaspelenur.com
Sat Jun 25 22:01:50 EDT 2005
[cross-posting to rails and typo lists]
I'm tinkering with the code for typo, a rails-based blog engine.
Typo has an XmlController with actions "rss" and "atom" which generate feed.xml
files, and it uses a caches_page declaration to cache the files that get
generated by those actions. It also has a Sweeper (Observer) class that expires
those cached files when a blog post is created or modified:
The normal behavior is that the files get deleted when expire_cache is called,
and then re-created the next time the XmlController action is invoked.
Now, I'm trying to force the files to be re-cached immediately after the
expire_cache call from the Sweeper class. However I could not find a way to do
I've tried several ways, including instantiating the controller in the sweeper
and calling the actions directly (which doesn't work), and the closest I got was
using render_component_as_string from the base ApplicationController. That
sort-of works in that it at least it calls the proper XmlController action, but
it has two problems: the pages aren't cached, and also the response type changes
to xml (which confuses the browser since the response is a redirect).
I wonder if anyone has a good idea of how the caching and stuff works, and what
I can do to force certain controller actions to run and get cached as if they
had been invoked by the browser, but instead invoking them from within an
observer or controller.
I'm using rails 0.12.1 on ruby 1.8.2.
Thanks in advance for any help, please let me know if you need any more info.
More information about the Typo-list