Heroku:在视图中显示Git修订哈希和时间戳? [英] Heroku: Display Git Revision Hash and Timestamp in Views?

查看:116
本文介绍了Heroku:在视图中显示Git修订哈希和时间戳?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我在 Heroku 上部署了Rails应用程序。如何在我的视图中显示这些信息?


  • 上次修订的Git哈希值

  • 最后一次修订版的时间戳记
  • 使用提交散列函数设置一个环境变量 ENV ['COMMIT_HASH']



    至于时间戳,您可以点击 github api ,如果你在那里托管你的代码。看起来 ruby​​-github gem 可以帮助你解决这个问题,或者你可以用< a href =http://rubygems.org/gems/httparty =noreferrer> HTTParty 。


    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

    解决方案

    Heroku sets an environment variable with the commit hash ENV['COMMIT_HASH'].

    As for the timestamp, you could hit the github api with the hash if you host your code there. Looks like the ruby-github gem can help you with this, or you could do it yourself with HTTParty.

    这篇关于Heroku:在视图中显示Git修订哈希和时间戳?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆