Pre-generating cached Stylesheets and Javascripts with Rails 2.0
We just switched autoki over to Rails 2.0.2 in the last days. While the transition we replaced the asset_packager plugin with the new Rails 2.0 :cache => true option in stylesheet_link_tag/javascript_include_tag.
As our assets (public/*) are served from an apache webserver that has its own checkout of the project, we can’t let Rails generate the all.css/all.js files on the fly when the first request comes in. Instead we have to pre-generate them at deployment. For asset_packager we had a capistrano task that did just that. Rails doesn’t have that. Instead the logic to generate the files is built right into the link/include methods in the AssetTagHelper(!). So now we are simply doing this in our capistrano recipe:
Fire up a mongrel, curl the start page, bring it back down. Feels a bit overkill but it works. (at least I hope it will when I’ll first try it later today)
Tags: assets, asset_packager, cache, rails, rails20





December 21st, 2007 at 4:44 pm
I hope so too…but perhaps you won’t try it only a few minutes before feierabend…;-)
December 21st, 2007 at 5:35 pm
you bet i will. again. why do people never learn from their past mistakes? like yesterday.
December 21st, 2007 at 6:20 pm
I don’t take bets…;-)
December 21st, 2007 at 6:50 pm
i did it and of course it didn’t work because there’s a typo in the script. (fixed it)
December 21st, 2007 at 7:46 pm
of course this still doesn’t work - stale pid files, mongrel still running because the previous deployment didn’t go through and that. more on that later.
January 24th, 2008 at 1:40 pm
[...] a previous post I wrote about how we wanted to pregenerate our packed assets simply by firing up a mongrel on [...]