Thursday, March 13, 2008

Cool Rails SVN tidbit - showing the revision #

If you want to show the SVN Revision number on your page - this helps the test team - add this code to your site:

<%= `svn info #{RAILS_ROOT}`.match('Revision.*') %>

Those are back-quotes. This will cause a shell command to be run.

If you add it to your environment.rb like so:

$svn_revision = `svn info #{RAILS_ROOT}`.match('Revision.*')

Then it is run when the server starts and you can access it on any page...

<%= $svn_revision %>

1 comment:

  1. Hey Mark, look at my Rack middleware: