HtonS
HtonS

Reputation: 301

Rails 3.1.0 Problems using haml - Missing template error

I'm trying to use haml in my project, I have a controller class and a view template, .html.haml

Here is my gemfile:

source  "http://rubygems.org"
#use Haml for templates
gem 'haml' '3.1.6'
#use Ruby debugger
group :development, :test do
gem 'ruby-debug19'
end
group :assets do
gem 'therubyracer'
end

I ran bundle install and restarted rails server many times, but haml doesn't even appear in bundle show.

I updated haml using gem, still no result.

haml --rails doesn't work - invalid option

vendor/plugins folder is empty

If I run rails server and open "http://localhost:3000/myindex", which I have a controller and a view template for, I get template error

Missing template movies/index, application/index with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}. Searched in:

haml isn't there in handlers at all.

I tried to add

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

to config/application.rb. Didn't work

Searched the web a whole day, read a lots of suggestions, but none of them helped.

bundle just refuses to install haml gem properly. Without indicating it as error. It simply ignores the gem.

Oh, and I ran haml index.html.haml on my template: html is generated perfectly. I made it very simple for test purposes.

Rails v: 3.1.0

Ruby v: 1.9.2p290

haml v: 3.1.6

Upvotes: 3

Views: 2231

Answers (2)

HtonS
HtonS

Reputation: 301

I found the cause. I've created a new file "gemfile" when I had to edit existing "Gemfile", case-sensitive! So bundle just was reading a wrong file.

Upvotes: 1

Peter
Peter

Reputation: 132367

Use haml-rails instead of haml. And delete the version string or add a comma:

gem 'haml-rails'
# or potentially
gem 'haml-rails', '3.1.6'

Upvotes: 4

Related Questions