Rails: display last deployment date in web application

I would like to show in our application when the last production rollout was made, as a means to demonstrate the constant desire for improvement, etc. etc.

From head to toe I am thinking of getting last_updated_at from one of the files, but I would like to hear other thoughts.

What is the best way to dynamically set the last release date?


Thank,

Josh

+3
source share
2 answers

Thanks mpd, which pointed me in the right direction.

For those interested in doing something like this, this is a quick and dirty method that can probably be refined and reorganized.

app/controllers/application_controller.rb :

private 

def app_last_updated_at
  if File.exist?(RAILS_ROOT + "/REVISION")
    timezone = "Mountain Time (US & Canada)"
    @app_last_updated_at = File.atime(RAILS_ROOT + "/REVISION").in_time_zone( timezone )
  else 
    @app_last_updated_at = "Not Long Ago."
  end
end

, ( - ).

, :before_filter application_controller.rb.

before_filter :app_last_updated_at

, , - :

<%= 
unless @app_last_updated_at.nil? 
  if @app_last_updated_at.is_a? Time 
@app_last_updated_at.to_s(:long)
  else
@app_last_updated_at 
  end
end
%>

, . , ApplicationController , .

+3

Capistrano. . , ,

+2

Source: https://habr.com/ru/post/1742511/


All Articles