In this particular book, the author uses Haml instead of Erb for templating views in the sample code. When I'm reviewing a book, I like to actually exercise as much of the sample code as I reasonably can, as it tends to be among the hardest stuff to get right, and among the easiest ways to discourage a reader when it's not right. But Rails defaults to Erb for templating, and I'm not exactly Haml-enabled.
What's a geek to do?
Well, my friend Google had a thing or two to suggest, but the process is slightly non-trivial so I thought I'd collate it here, thusly:
- NB: All commands are entered from your Rails 3.0 application's root directory.
[your_app]/Gemfile, and add the line
gem 'haml'somewhere convenient.
[your_app]/config/application.rb, and add the line
g.template_engine :hamlto the
config.generatorsblock (uncommenting the block if necessary).
gem install haml
haml --rails .
git clone git://github.com/psynix/rails3_haml_scaffold_generator.git lib/generators/haml
That last bit is particularly important for allowing Rails' scaffold generators to Do The Haml Thang(TM) when generating view templates.
Now back to my regularly scheduled tech review ...
P.S.: The book is going to be awesome. Reserve your copy now!