Since my Metasploit 3.0 under Ubuntu 7.04 post has been popular, I figured I'd update this for 3.1 under Ubuntu 8.04.
Basically it's the same, only less.
sudo apt-get install ruby libreadline-ruby libopenssl-ruby
for the basics, then you need
sudo apt-get install rubygems
for the web stuff - no more gems calls to install Rails, apparently - and
sudo apt-get install libglade2-ruby libgtk2-ruby
for the GUI. One of those recommends graphviz, which I installed because it's a nice tool to have at your disposal. And that's it.