Displaying Deployment Date and Time and Git Revision Number in Rails Views
I had a need to display the deployment date and time (timestamp) and the current revision/version number in the footer of all our pages in our Rails application. Our users always were asking "Did you update the web site?" Thanks to capistrano , the deployment tool, this turned out to be fairly easy. Capistrano already collects the deployed version and places it into a file named REVISION in the deployment directory. The contents hold whatever is reported by your version control software. For git , this is a SHA1 hash. For the deployment timestamp, thankfully capistrano uses a timestamp for the deployment directory name. So we can just parse the path, looking for the timestamp. Below is the helper code, please let me know if there's a better way. [sourcecode language='ruby'] # pulls from the capistrano directory structure def deploy_timestamp if Rails.env.production? RAILS_ROOT.split('/').last else "Undeployed" e...