Working Remotely? Thinking about it?

Are you a member of a geographically dispersed team? Are you thinking of working remotely, or hiring remote developers? Wide Teams is my new blog and podcast for distributed teams. Check it out for getting started guides, tips and best practices, news, interviews, screencasts, and more all about working remotely and collaborating with wide-spread teams.

Revision-Stamp Your Rails Apps

2008 July 3
by avdi

One of my biggest pet peeves in doing QA is when I spend half a day trying to track down why a bug I thought I’d fixed has cropped up again, only to discover that the reporter was looking at an old version of the application. Good revision tracking is vital to doing efficient QA. Here’s a little trick for removing any uncertainty about what version of the app you’re looking at.

Capistrano, after it exports an application from an SCM repository (such as a Subversion repository), writes an extra file to the application’s root directory. The file is named “REVISION”, and, as you might imagine, it contains the revision number that was exported. Displaying this information in your application’s UI is straightforward. Here’s the addition I made to a view partial that is displayed on the application’s home page:


Application revision <%= app_revision %>

And here’s the app_revision helper method:

module ApplicationHelper
  # ...
  def app_revision
    revision_file = File.join(RAILS_ROOT, "REVISION")
    if File.readable?(revision_file)
      IO.read(revision_file)
    else
      "unknown"
    end
  end
end

Of course, this isn’t very efficient – it will re-load the file every time a page is rendered. Optimization is left as an exercise to the reader. But it accomplishes its purpose: now whenever someone reports a bug in the app, I can ask them to go to the application home page and tell me what the revision number is. No more trying to remember whether I pushed out the latest changes to the beta server.

Bookmark and Share
Creative Commons License
This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Related posts:

  1. Rails 3 resource routes with dots; or, how to make a Ruby developer go a little bit insane
  2. The Trifecta of FAIL; or, how to patch Rails 2.0 for Ruby 1.8.7
  3. Smart Requires in Ruby
  4. Confident Code at B’More on Rails
  5. Double-Load Guards in Ruby
blog comments powered by Disqus