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.
- Edit
[your_app]/Gemfile
, and add the linegem 'haml'
somewhere convenient. - Edit
[your_app]/config/application.rb
, and add the lineg.template_engine :haml
to theconfig.generators
block (uncommenting the block if necessary). gem install haml
bundle install
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!