Capistrano 1.3.1

I’ve been remiss in announcing recent Capistrano releases, so I’m making up for lost time now. Capistrano 1.3.1 is now available!

Capistrano, for those of you that are late to the game, is a utility for executing commands in parallel on multiple remote machines. It comes with support for vastly simplifying the deployment process of Rails applications, but can be customized to work with virtually any environment.

Since 1.2.0, the following enhancements and changes have been made:

  • You can encode the username and port for a host in the host string. Does one machine require a different user than another? A non-standard port for SSH access? It’s as simple as:
role :app,  "app1.host.com"
role :web,  "webuser@web1.host.com"
role :db,   "db1.host.com:1234"
role :file, "fileuser@file1.host.com:1234"
  • You can pass an :as option to sudo, to specify which user a command should be run as:
sudo "spinner", :as => "app"
  • If you define a “.caprc” file in your home directory, Capistrano will automatically load that file on every invocation. (It has the same format as any other Capistrano recipe file.)
  • Assets in the images, javascripts, and stylesheets directories are now touched after updating the code, to ensure that Rails’ asset timestamping feature works correctly.
  • Make sure new setups and checkouts are group-writable.
  • Do not run the cleanup task on servers marked “no_release”.
  • Rake integration is now deprecated. You should be invoking ‘cap’ directly. A future release will remove rake integration altogether.

Feel free to read the changelog several other fixes and tweaks. It might be a few hours before the 1.3.1 gem reaches all the mirrors, but when it gets there, a simple “gem install capistrano” ought to do the trick!

DailyKos considers Ruby on Rails

Earlier this week, Hunter, uber technocrat at DailyKos.com started talking about how they will build the next version of DailyKos. The discussion has been going for a day or two now with over 700 comments as I write this.

While DailyKos is the highest-traffic political blog in the US, I don’t think it’s particularly newsworthy that they are considering Rails. In fact, I think it’s quite the opposite. What I do find interesting is the evolving discussion about the choices. Hunter essentially set out Perl/mod_perl, Python/Django and Ruby/Rails as the main choices. What people have to say about the differences and why they would choose one over the others makes for some really I-should-have-been-in-bed-an-hour-ago reading. Some of what people think they know about Ruby and Rails seems to be out of date or otherwise misinformed, but there are some good arguments on all sides.

If you are gearing up to have a conversation with management about picking Rails for a big project, take a read to see in one place all the arguments you will have to deal with!

Rails 1.2: Release Candidate 2

This is it. We’re a mere two shakes of a lamb’s tail from releasing the final version of Rails 1.2. But before we light the fireworks and pop the champagne, we’ll just do one itsy, bitsy, tiny test run. Like wearing protection glasses in downtown Copenhagen on New Year’s. You know, just for precautions.

So please do give it a good run. We’re looking for STOP THE BOAT and HOLD THE PRESSES kind of issues for this one. Nothing else will stop it (but please do report every thing you find any way).

For a reminder on how to install and what’s new, see the release notes for Release Candidate 1. We also did a series of highlights for Active Record, Action Pack, and Active Support. Read those and hold your breath in anticipation. Unless a surge of heinous issues appear, we’re expecting the final version to land some times next week.

Yay, hurray!

Using custom mime types

So, you’ve started using Rails’ new mime type support with responds_to, but you were wondering how to add your own custom types? Luckily, Geoffrey Grosenbach (aka topfunky) is there to show you the way. His example involves registering an extension for .png, and generating a custom icon for an order in his shopping cart with some RMagick-fu. His example looks something like this:

Mime::Type.register "image/png", :png

# then in your controller action
def show
  respond_to do |format|
    format.html { }
    format.png { }
  end
end

Mime::Type.register will add the image/png mime type to the collection of mime types, bind it to the .png extension. It also creates a special Mime::Type instance at Mime::PNG. Check out the great post and the comments for more tips on caching and RMagick.

Note: After some investigation, I’ve found that using Geoff’s :format hack is not required on Rails 1.2 if you make the request with the :format parameter. Using routes like formatted_post_path(@post, :xml) will give you a path like “/posts/1.xml”. Accessing that will write public/posts/1.xml, regardless of what the page_cache_extension is.

A brief introduction to Active Resource

Rick Olson is getting jiggy with Active Resource these days and decided to spread the love with a brief introduction to the newest member of the Rails framework family. He takes you through how to use ARes as a client for the Beast forum in a few simple steps. Get your REST face on and enjoy.

Working with Rails? Tell the world

Working With Rails is an attempt to index all the developers around the world working with Rails. It offers a few ways to browse the index and while the authority and popularity lists are perhaps a tad silly, I love looking at the country list. 3 programmers in Peru, 1 in Kazakhstan, and 3 in Uzbekistan. How cool is that?