Locomotive / Typo bug

I’ve been trying to get typo working on my mac, using the very shiny Locomotive. Sadly, I kept getting display errors in my sidebar. After spending 3 hours looking at it last night, I’m now pretty sure that it’s a bug in YAML::load, which is called from inside ActiveRecord::Base#object_from_yaml. It works fine on my FreeBSD server running ruby 1.8.4. But under Locomotive (ruby 1.8.2), Instead of getting back a hash, I get some internal YAML class. Hmmm.

Thankfully, a simple patch is all that’s required to get things working properly.

Index: app/models/sidebar.rb
===================================================================
--- app/models/sidebar.rb       (revision 724)
+++ app/models/sidebar.rb       (working copy)
@@ -27,7 +27,10 @@
   end

   def active_config
-    self[:active_config]||{}
+    ac = self[:active_config]||{}
+    # XXX Work around a bug in some versions of Ruby / YAML.
+    ac = ac.value if ac.respond_to? "value"
+    ac
   end

   def html_id

I’m so glad that I imported typo into subversion on a vendor branch. It makes this sort of thing a heck of a lot easier.

I should go and file a bug in the typo trac. But I have to admit to not being sure that it’s up and running properly yet…