Archive for June 2008

Breaking the Rails static asset timestamp cache in development mode

Rails automatically adds the File.mtime to static assets when using stylesheet_link_tag and javascript_include_tag. The file’s mtime is cached to prevent excessive file system access… even in development mode. This is problematic in a Facebook canvas during development mode because often you won’t immediately see the changes you make to your stylesheets and javascripts.
Here [...]

Cleaning up old releases

Instead of relaying on running cleanup of old releases via capistrano, we have a cron job to only keep releases for last two days (but at least three latest).

#!/usr/bin/env ruby

require ‘fileutils’

KEEP_RELEASES = 3
KEEP_DAYS = 2
EXCLUDE_APPS = %W(uploadr)

cut_time = (Time.now.utc – KEEP_DAYS*24*60*60).strftime("%Y%m%d%H%M%S").to_i

Dir['/u/apps/*'].each do |app|
next if EXCLUDE_APPS.include?(File.basename(app))
dirs = Dir["#{ app }/releases/*"]
fresh [...]

Rake task for syntax checking a Ruby on Rails project

Here’s a quick rake file that will crawl through your Rails project and syntax check ruby, erb, and yml files. You should always run this before doing a “cap deploy” and it even doesn’t hurt to run it before a “svn commit”.

require ‘erb’
require ‘open3′
require ‘yaml’

task :check_syntax => [:check_ruby, :check_erb, :check_yaml]

task :check_erb do
(Dir["**/*.erb"] [...]

ESI & Mongrel-ESI.. Request for Feedback

.thumbnail { padding:12px; float:right}

The Railsconf08 talk on ESI & Rails has sparked some interest in the community, and Todd, the core mongrel-esi maintainer, is asking for feedback on the mongrel-esi mailing list.
The latest rumor is he is working on a nginx port of mongrel-esi, which I have to [...]