We tried to update our Rails 3.2.13 app to Haml 4.0.0 (via haml-rails 0.4) and got the following problem on a staging server:
ActionView::MissingTemplate: Missing template welcome/index, application/index with {:locale=>[:de], :formats=>[:html], :handlers=>[:erb, :builder, :arb, :slim, :coffee, :md]}. Searched in: * "/var/www/compeo/releases/20130319124315/app/views" * "/var/www
Where:
welcome#index
[GEM_ROOT]/gems/actionpack-3.2.13/lib/action_view/path_set.rb, line 58
Did I miss any update instructions?
We tried to move 'haml-rails' out of the :assets group in the Gemfile, but that did not help.
We do not require 'haml' in our Gemfile and do not have any initializers. Anything missing?
We do not require 'haml' in our Gemfile
Try adding it to your Gemfile.
Sorry, I don't have the time right now to give it another try.
You don't have time to add 'gem "haml"' to your Gemfile and restart your
app? Ok. Anyway that will very likely solve your issue for you when you
have the time to try it.
Sent from my phone
I thought it would only occur on a production-like environment. I might be wrong.
So now it's required to add 'haml' to the Gemfile next to 'haml-rails'? Is that mentioned somewhere?
Well, the Readme says to add it to your Gemfile "as well as" Haml-rails, so
yes. I've recently noticed this issue with Haml 3 and ActiveAdmin as well,
so it's not due to an intentional change in Haml 4.
You can not always rely on a gem's status as a dependency to another gem in
your Gemfile as sufficient to ensure it's properly activated in Rails,
because it might never be explicitly required by the gem. If you want to
_ensure_ any library is activated you must put it in your Gemfile.
I'm not trying to belittle your bug report. I'd like to get to the bottom
of it, but in the mean time I'm trying to help you come up with an easy
solution to your immediate problem.
Sent from my phone
Okay, sorry, you are right: Your Readme clearly states that haml-rails can be added _as well_.
Maybe the guy that installed Haml in the first place just scanned the instructions in a rush:

You might avoid this by making the installation instruction easier to scan:
Using Haml with Rails
To use Haml with Rails, simply add Haml to your Gemfile and run
bundleafterwards:gem 'haml'If you'd like to replace Rails's Erb-based generators with Haml, add haml-rails to your Gemfile as well.
I tried to update again. The template registration works without gem 'haml' in the Gemfile in development, but not in staging / production.
I will open an issue in haml-rails. Thanks for your efforts.
Yeah, I think your suggestions would improve the docs. Sometimes things seem obvious to me when they're not because I've been using Haml for so long, so some help editing to improve clarity would be quite welcome.
I'll look into how Haml is initialized to see if there's a way to make it work when it's simply included as a dependency, and not explicitly in the gem, but a priori I'm not sure what's involved.
You might want to check in the source code of Haml-rails and see if for any reason it doesn't require anything in production. I don't actually think it should - the point of haml-rails is to offer generators for use only in development mode, so I don't see this as a bug on their side at all.
I think checking the source code of haml-rails is not necessary because 鈥撀燼s you said 鈥撀爄t is not reasonable that haml-rails gets loaded in production.
Well... I do wonder why it was not necessary to require haml explicitly with haml-rails 0.3.4.
But I think it's okay to avoid this potential confusion by providing a clear instruction / explanation.
The reason why people might be confused is that sass-rails, compass-rails, jquery-rails, etc. all require their core lib (sass, compass, jquery, ...) and haml-rails does not. It has good reasons not to do that but that might not be clear to its users.
Why does haml-rails not require haml? And why does this break only in production? I'd love if (at least) the behaviour in development and production were the same so that we don't have to have an unexpected debugging session when trying to push an app to production.
For those that are using rails engines:
Strangely, I just encountered this issue. We had pruned haml from the gemspec of our rails engine, but it was working fine when RAILS_ENV=test, which I assume means that some test only dependency was causing it to be included.
I added both haml and haml-rails back, yet we still don't have a haml handler when RAILS_ENV=development:

In our main file for our engine lib, I added require 'haml' to ensure it was loaded when the engine was, and that solved the problem.
@rosskevin thanks so much.
I had require "haml"; require "haml-rails" in the engines ApplicationController but I could see from the error haml was not registered as a handler.
Adding require "haml-rails" or require 'haml' to lib/my_engine/engine.tb fixed this issue.
The original error was
ActionView::Template::Error:
Missing partial <SNIP>
:handlers=>[:raw, :erb, :html, :builder, :ruby]
Notice no haml in handlers.
And why does this break only in production? I'd love if (at least) the behaviour in development and production were the same so that we don't have to have an unexpected debugging session when trying to push an app to production.
I guess because we installed haml on the local system with gem install haml at some time.
Most helpful comment
For those that are using rails engines:
Strangely, I just encountered this issue. We had pruned
hamlfrom the gemspec of our rails engine, but it was working fine whenRAILS_ENV=test, which I assume means that some test only dependency was causing it to be included.I added both
hamlandhaml-railsback, yet we still don't have ahamlhandler whenRAILS_ENV=development:In our main file for our engine lib, I added
require 'haml'to ensure it was loaded when the engine was, and that solved the problem.