I’m getting Ruby on Rails set up on a fresh installation of Snow Leopard. After battling (and beating) MySQL and Sphinx problems, I’m stuck on a stupid error related to HAML.
Essentially I’m getting a missing template error for every view that uses HAML. I can add a blank xxx.html.erb file and and a (blank) page loads fine. But xxx.html.haml throws the error, even though that file definitely exists in the appropriate directory.
Here is the error from the development server:
ActionView::MissingTemplate (Missing template sections/index.erb in view path app/views):
haml (2.2.4) rails/./lib/sass/plugin/rails.rb:19:in `process'
I am using the haml gem (2.2.4), rails gem (2.3.4), and ruby 1.8.7. I did run haml –rails . from my RoR app root directory; the init file is in the vendor/plugins/haml directory. I have confirmed that “require ‘haml'” => true via IRB.
Any help would be appreciated!
In response to Yaraher:
Tried un- and re-installing, which raised no errors except with the rdocs (“Could not find main page README.rdoc”).
In script/console:
>> require 'haml'
=> []
Update:
Installing an old version of Rails known to work with HAML in this project seems to have “fixed” the problem. I’d still be curious to hear a real answer to this problem — I don’t want to be stuck at 2.3.2.
sudo gem install -v 2.3.2 rails
Update 2:
This is definitely caused by a difference between Rails 2.3.2 and 2.3.4. With both gems installed I can set which is used in my environment.rb file. HAML works fine with 2.3.2 and breaks as described with 2.3.4.
Time for the embarrassing answer to this question:
There is a difference between Rails 2.3.2 and 2.3.4 that does not recognize
xxx.haml.htmlfiles as files that should be parsed by HAML (or ERB); this worked fine in 2.3.2. HAML files should always be namedxxx.html.hamlanwyay, so this isn’t even a bug.I didn’t realize that this was the problem because I had the “hide file extensions” option turned on (on by default) in my fresh Snow Leopard installation. So when I tried switching the file extension through Finder to
html.hamlto test this, it actually changed it tohaml.html.hamlor some nonsense.Moral of the story: I ran the following script and now HAML works with Rails 2.3.4.