views:

35

answers:

2

I'd like to show in our app when the latest production deploy was made, as a means of showing an ongoing commitment to improvement, etc, etc.

Off the top of my head I'm thinking of getting a last_updated_at from one of the files, but I'd like to hear other thoughts.

What's the best way to get the date of the latest production deploy dynamically?


Thanks,

Josh

+1  A: 

You can do it pretty easily with Capistrano. Take a look at this link I think it does exactly what you want Deployment date

mpd
Thanks for the link man. I'm going to post a more detailed solution from my efforts later today.
Josh Pinter
np, I look forward to seeing your results.
mpd
+1  A: 

Thanks to mpd who pointed me on the right direction.

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

In app/controllers/application_controller.rb put this method in the private section:

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

Obviously, replace the timezone with your own (or you can do something fancy for individual user timezones).

In order to have this run all the time I use a :before_filter' (# TODO: refactor so it's not run everytime, only when a new deploy happens). So put this at the top of yourapplication_controller.rb`

before_filter :app_last_updated_at

And then to actually show this last updated at date, you just throw this or something like it in a layout or a partial or whatever:

<%= 
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
%>

Hopefully that helps others. Like I said, I'm not keen on having it run in the applications_controller for every access, so suggestions would be appreciated.

Josh Pinter