Rails Magazine Issue 1

skitched-20090228-223944.jpgThe first issue of Rails Magazine is out! I’m super excited because I’ve got an article in there on receiving email with Rails. Go check it out. I can reproduce the article here after the publication has been out for 30 days so stay tuned for that.

Ruby Interpreter Comparison

InfoQ_ Ruby VMs_ A Comparison-1.jpgI did a talk at QCon a while back on the different Ruby Virtual Machines. You can check out the presentation the InfoQ web site: Ruby VMs: A Comparison.

Offline Gem Server RDocs

Twitter _ Jesse Newland_ sinatra-rubygems + Passeng ....jpg

Get Sinatra, Rubygems, and Passenger working for offline RDocs? Count me in. I saw this and new I had to have it. I’ve been on some long plane rides recently and I frequently find myself wanting to look up something from a gem’s documentation while I’m coding. You can use the gem server command but that’s just such a pain to do every time you want to look something up. I hadn’t really given it much thought that there might be an easier way until I saw Jesse’s tweet about it. Having this offline using passenger at http://gems.local is great but I wanted to have a little more searching baked in. Here’s how I did it:

  1. Install the hanna gem from mislav.

    You may need to have the HAML gem installed for this to work. The hanna gem is a great theme for rdoc output. It includes javascript to make some ajaxy type search so you can filter methods by typing in to a text field in one of the frames on the left. It took me a little while to find this theme. It’s the one currently in use on GitRDoc, which is a great resource (if you’re online).

  2. Tell rdoc to use the hanna theme

    In order to tell rdoc and gem to use this when you use the "gem" command, you need to add to your .gemrc. Beware that this will affect all future rdoc generation when you install a gem. Add the following to ~/.gemrc:

  3. Regenerate your rdocs

    You then need to regenerate all of your rdocs with this theme. You can do this by executing the following:

  4. Get sinatra-rubygems

    Clone my fork of Jesse Newland’s sinatra-rubygems from GitHub:

    git clone git://

  5. Add it to Passenger

    Hook it up to your passenger preference pane and set the name to "gems.local", restart Apache and you’ll be all set:

    passenger pref pane.jpg

After you complete the above steps, everything should be working. Enjoy! This will come in handy next time you don’t have internet access and need to look up some methods. I’d like to give a special thanks to Jesse Newland for releasing the sinatra-rubygems app.

Update: k776 points out in the comments that this doesn’t work on the latest version of rdoc, which is 2.4.1 as of this writing. It seems 2.3.0 is the version to go with.

Turning Off Webrat’s Automatic Browser Opening

If you’re using webrat for doing your integration testing with Rails and you’re on OS X you may notice that webrat opens an html version of the failing test every time you run it. This can be fairly annoying if you’re running autotest. I didn’t see how to turn it off in the documentation but I found on this page that you can turn it off by doing the following:

This doesn’t work for the gem version I had installed but only with the GitHub version of brynary-webrat.

Mepisto to WordPress Converter

As a recent experiment, I tried converting a blog from Mephisto to WordPress. After some quick Googling, I found out that Jason Gill had already largely solved the problem.

Unfortunately, his solution didn’t completely work for me because I didn’t want to launch Mephisto to do it and I have an aversion with that much code in a controller. Even if it’s just going to be run once. Even if it’s just locally. I know, I have a problem. Anyway, I wanted to launch it from the command line also.

I had been planning to move the Rails Envy blog to a different server and saw this as a good opportunity. The plan was to migrate the blog offline and put it on a separate subdomain (something like Once everything is totally working, I’d just point the main dns over. This is a fairly good strategy regardless of the application (blog, app, etc). First, though, I had to get that script working. Here’s what I came up with:

Leopard LoadError: no such file to load — sqlite3

I’m not quite sure why this happened, but I kept getting this error with Leopard and sqlite3:

LoadError: no such file to load -- sqlite3

I tried to gem install and uninstall sqlite3-ruby a few times but that didn’t work out. However, installing from source did. Head on over to the Rubyforge page and download the zip or tgz archive. Extract it and just run:

ruby setup.rb

After that requiring sqlite3 should work fine.

Innovation in Ruby

Just got done doing a presentation with Gregg Pollack at the Ruby Hoedown. The talk was on Innovation in Ruby in the last year. You can grab a cheat sheet over on the Rails Envy web site.

Backpack Ruby Script

Each week I edit the Rails Envy podcast. We use Backpack to work together on the stories each week. Each story is a note in the Backpack page:

Today while I was preparing the post, I remembered that Backpack had an API. A quick google turned up the Backpack API page with a link to the Ruby wrapper. About 10 minutes and some regular expressions later I had a script to auto format the weekly podcast links each week by just passing in the page id.

require 'rubygems'
require 'XmlSimple'
require 'ruby_wrapper'
stories = []
backpack ='username', 'api key');
backpack.page_id='the page you want'
notes = backpack.list_notes
notes = notes['notes'].first['note']
# {'title' => 'A note', 'id' => 'An id', 'content' => 'asdf followed by a url'}
notes.each do |note|
  story_link = note['content'].scan(/(http\:\/\/.*)$/m)[0]
  stories.push("<li><a title=\"#{note['title']}\" href=\"#{story_link}\" rel=\"nofollow\">#{note['title']}</a></li>".gsub(/\n/,''))
puts stories.join("\n")