1

So, I know there are multiple questions and solutions on StackOverflow about Haml not working on Rails, but those haven't helped me, that's why I try again (and try to document as precise as I can).

Today, I install Haml by doing gem install haml. This installed Haml, and I tried changing my index.html.erb to index.html.haml. I got the following error:

Error code

I googled and found some solutions on StackOverflow, mentioning I should restart my server (tried it, didn't solve it) and the second solution was: install haml-rails instead of just haml and then restart my server. That didn't work, so I uninstalled haml and haml-rails, after which I installed haml-rails again (I thought the might've been bugging eachother), but to no avail.

I then read somewhere that people didn't even have Haml in their gems-list when executing bundle show (yes, I also put the gem in my bundle list). So I tried that, and indeed, Haml doesn't show up in my list of installed gems.

So, I'm hoping someone can help me out, because I'm at a loss here. If you have any questions of if I should clarify something in more detail, please ask!

Rvervuurt
  • 8,589
  • 8
  • 39
  • 62

1 Answers1

0

Apparently, the problem was that I ran gem install haml-rails and didn't add it in my Gemfile. That's what solved the problem. I had no idea not adding it to the Gemfile and just installing it manually, could bring up errors. (Coincidentally, Marek Lipka wrote a comment with the "solution" at the moment of writing this answer).

Rvervuurt
  • 8,589
  • 8
  • 39
  • 62
  • This is because when you add a gem to the Gemfile, the Rails application kinda "requires" the Gem on server boot and loads the Gem's libraries. Also, you may notice that there is a ":require => false" option that can be used in your Gemfile for gems that are not required at boottime. This may be important sometimes to increase server boot speed, like when you're deploying on Heroku and Heroku shows up a "boot timeout error". A little bit more info here: http://stackoverflow.com/questions/4800721/bundler-what-is-the-require-false-on-the-gemfile-means – Kulgar Aug 12 '13 at 13:26