Rails scaffold, create .haml rather than .erb views

After being tired of refactoring .erb files to .haml I headed for a way to modify the rails generator that will create .haml view files rather than .erb view files.

After a while, I found what exactly I needed. ‘haml-rails’ is the name of the solution. This is how you do it.

Add the following line to your Gemfile:

gem 'haml-rails'

Then run the bundler (bundle install).

Now append the following lines in your application.rb file (at the end of Application class):

config.generators do |g|
   g.template_engine :haml

That’s it. Your new scaffolds will generate .haml files (and obviously haml syntaxes) for you.

This is much easier than Haml-scaffold.