views:

252

answers:

3

Let's say I have a Rails application deployed on Heroku. How can I display these pieces of information in my views?

  • The Git hash for the last revision
  • The Timestamp for the last revision
+1  A: 

There is grit installed on Heroku. So you can open the repository there using it.

repo = Repo.new(Rails.root + '.git')
last_commit = repo.commits.first
p last_commit.id
p last_commit.authored_date
Damien MATHIEU
Thanks for the tip. Unfortunately, it's not working for me in heroku console (would it be different in app itself?). After Repo.new, I get 'Grit::NoSuchPathError:' Any ideas?
Rich Apodaca
A: 

I think you need to config.gem 'grit' into your Rails app in order to be able to create the Repo object.

You can read about grit here http://github.com/mojombo/grit/

Daryl
A: 

The reason for this is because when your app is deployed onto the dyno grid to serve requests, it's compiled into a "slug" for fast deployment, and this slug doesn't have the git repo with it anymore.

tfe