Kenny Meyer

Top 6th percentile on StackOverflow.


Show latest commit ID in Rails

Published Sep 09, 2012

I find it useful to display the current git commit ID of my application:

In your application’s Gemfile add the grit gem, which is a Ruby wrapper for git, and run Bundler.

If you deploy your web application via Capistrano and git, then you can put the following in your app/helpers/application_helper.rb:

[gist id=3679774]

Make sure the repo you are deploying to is non-bare. If you are not sure about that, in the project’s directory run:

[gist id=”3679892”]

If you see a SHA-1 Hash, life is good.

Now in your template you can add the helper anywhere you like – most people prefer to put that info in the footer:

[gist id=”3679825”]

How easy was that!