Mar 19, 2010 @ 10:49 am

When you are developing an app or a website for your client, it is pretty common to setup a sandbox environment where your client can test and see the application while it is still in development. One thing I find useful is to display the last deployment date on the home page.

Here is a quick and easy way to automate the process :

Step #1 (we can have lots of fun)
I will consider that you use capistrano for deploying your app. The only thing you have to do in your capistrano recipe is to “touch” a dummy file to update its modification date.

namespace :deploy do
  desc 'Restart My App'
  task :restart, :roles => :app do
    run "touch #{current_path}/last_deploy"
  end
end

Step #2 (there’s so much we can do)
Now in application_controller, add a before_filter like this

before_filter :last_deploy

def last_deploy
  @last_deploy = File.new("last_deploy").atime rescue Time.now
end

Step #3 (it’s just you and me)
Display the date in the layout or in the view of your choice

<%= "Last deployment : #{@last_deploy}"%>

Edit : Oh, dear readers, I just want to let you know that RubyFleebie is now on Twitter.

Bookmark this post : These icons link to social bookmarking sites where readers can share and discover new web pages.
  • DZone
  • Reddit
  • del.icio.us
  • Digg
  • Furl
  • Technorati
  • StumbleUpon
Posted under : short & sweet
3 Comments

I think you could also use the REVISION file that capistrano places by default during a deploy. You could also get the SVN/git revision from this file by reading it.

Thanks for the tip!

Comment by : Ian NeubertNo Gravatar
— March 19, 2010 @ 11:49 am

You could also pull the timestamp from the most recent folder within the releases directory, as Capistrano uses timestamped folder names as a way of separating revisions of code over different deploys. Nice idea :)

Comment by : Josh NesbittNo Gravatar
— March 19, 2010 @ 12:29 pm

Thanks guys for these nice alternatives!

Comment by : FrankNo Gravatar
— March 19, 2010 @ 1:26 pm




Leave a comment
Name (required)
Email (will not be publish) (required)
Website