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
Let's say I have a Rails application deployed on Heroku. How can I display these pieces of information in my views?
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
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/
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.