So.

Is it as fun as it used to be?

Want Haml? Stuck using an old version of activesupport?

Then this is what you need to do (if you haven’t already figured this out).

I am using Rails 1.0.0 for an application at my company, and for annoying reasons, I can’t at the moment switch to Rails 1.2.3. This requires activesupport 1.2.5 to be installed. Since there are a lot of things using activesupport other than Rails I’ve also got version 1.4.0 installed.

If you install the haml gem and try to do something like this in a ruby script:

require 'haml'

engine = Haml::Engine.new("%p hello world!")
puts engine.render

you’ll get some ugly looking exception complaining about activesupport 1.4.0 and 1.2.5.

Worse, just by having installed the haml gem other things will break. For example, Merb won’t start because of that same exception.

Luckily, this bit of code works:

begin
  require 'haml'
rescue
  require 'haml'
end

engine = Haml::Engine.new("%p hello world!")
puts engine.render

and merb will start again if you replace the require 'haml/engine' in the lib/merb/template/haml.rb in the merb gem with:

begin
  require 'haml/engine'
rescue
  require 'haml/engine'
end

Written by hutch

June 18, 2007 at 9:51 am

Posted in Ruby, webapps