Trevor Burnham

Sure, it works in practice…

Haml 3 (beta) on Rails 3 (beta)

April 22nd, 2010

[Note: This post will baffle my usual readers. I intend to bifur­cate (tri­fur­cate?) my blog into multiple blogs in the near future: one for development-​​related stuff, another for startup-​​related stuff, and another for personal stuff. Until then, I feel that I have a respon­si­bil­ity to help those Googling for solu­tions to the exact same problems that have been befud­dling me in my life as a pro­gram­mer; this post is entirely for that purpose.]

I love Sass, the stylesheet-​​generating cousin of Haml. It’s so much syn­tac­ti­cally sweeter than CSS, it lets you define vari­ables and mixins like this handy border-​​radius shortcut, and it works seam­lessly in Rails. And Sass 3 is the best version yet, for a number of reasons. Mean­while, if you’re creating a new Rails project, the Creator Himself has pro­claimed that you should be doing it with Rails 3.

But right now, the instal­la­tion instruc­tions for this lethal com­bi­na­tion don’t exactly parse. So here’s what you need to do:

  1. Install the latest Rails (instruc­tions here)
  2. Install the latest Haml/​Sass dis­tri­b­u­tion: gem install haml --pre. (If you get an error, try updating RubyGems: gem update --system.)
  3. Run haml -v and note the version number. Mine is 3.0.0.beta.3 (delight­fully code-​​named “Classy Cassidy.”)
  4. Create a Rails project, e.g. with rails ~/MyProject
  5. Open up Gemfile in the project root and add the line gem 'haml', '3.0.0.beta.3', sub­sti­tut­ing whatever the version number was in step 3.

And that’s it! Running haml --rails ~/MyProject appears to be harmless but unnec­es­sary. If I’m wrong about that, someone please let me know.

Related: If you want to get Ruby 1.9 installed on your Mac, I strongly urge you to use Homebrew. If you’re curious about how to set Rubygems so that you don’t have to sudo it, follow the instruc­tions at this page under the heading “Fixing Rubygems.

Tags:   No Comments

0 responses so far ↓

Comments are closed.