22
votes

I have tried to render some files with HAML in Rails 3 without success.

My testfiles have the extension .html.haml.

In my Gemfile, I have the line gem 'haml' and have run bundle install.

When I run my app, I get the following error:

Template is missing

Missing template posts/index with {:locale=>[:en, :en], :formats=>[:html], :handlers=>[:rjs, :rhtml, :rxml, :builder, :erb]} in view paths "/Users/piet/Sites/blog/app/views"`

Any idea on how to resolve this?

3
Did you restart your rails process? - Andrew Vit
I renamed yourview.html.erb to yourview.html.haml and it showed Template is Missing. So I restarted rails server and it's working now. - Bao

3 Answers

69
votes

For rails 3 all you need to do is add:

gem "haml-rails"

to your Gemfile, then do a "bundle install"

See https://github.com/indirect/haml-rails

If you still seeing the error try restarting your server.

2
votes

If you are upgrading from Rails 2 to Rails 3, make sure that this is close to the top of your config/application.rb file:

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

It should be right below

# Put this in config/application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
1
votes

HAML does work without issue in Rails 3.. Two things:

  1. Make sure your route file has resources :posts
  2. Make sure you have the file app/views/posts/index.html.haml

Could you try that? And confirm that Andrew's comment about restarting Rails has been tried as well.