Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Todd Squitieri
8,001 PointsKeyword Ensure Error with HAML File
I'm following a tutorial and using a HAML file extension for the index file. Whenever I try to preview my app, I get the following error message:
#{hamlout.adjust... ^ /home/ubuntu/workspace/app/views/jobs/index.html.haml:4: syntax error, unexpected ')' ));}
**\n
{_hamlout.adj... ^ /home/ubuntu/workspace/app/views/jobs/index.html.haml:5: unknown regexp option - p /home/ubuntu/workspace/app/views/jobs/index.html.haml:5: syntax error, unexpected $undefined ));}**
\n\n", -1, false);::Haml... ^ /home/ubuntu/workspace/app/views/jobs/index.html.haml:5: unterminated regexp meets end of file /home/ubuntu/workspace/app/views/jobs/index.html.haml:5: syntax error, unexpected end-of-input, expecting keyword_end
The file this error is talking about is the index.html.haml file which contains this TINY bit of coding:
= @jobs.each do |job|
%h2= link_to job.title, job
%p= job.company
What on Earth am I doing wrong?
Any help would be much appreciated.
Thanks so much in advance!
Sincerely,
Todd
6 Answers
Maciej Czuchnowski
36,441 PointsIs your indentation correct? In HAML proper indentation is everything.
Todd Squitieri
8,001 PointsHi Maciej
To the best of my knowledge, the indentation is okay. I tinkered with the indentation all of last night, and still got the same error.
Not sure if it makes any difference (It probably doesn't), but I am doing this coding in Cloud 9, as opposed to the local server. Maybe this has something to do with it???
Thanks so much for reaching out!
Todd Squitieri
8,001 PointsI just changed the indentation again, but now I get a new error:
Showing /home/ubuntu/workspace/app/views/jobs/index.html.haml where line #2 raised:
undefined method each for nil:NilClass
Not sure what this means, but any help would be awesome!!
-T
Maciej Czuchnowski
36,441 PointsThis suggests that the @jobs variable was not set for some reason when the view got generated.
Todd Squitieri
8,001 PointsI removed the HAML (I was using version Alpha 2), bundle installed, took down the server and then put it up again. Re-added an older version of HAML (4.0.6) and bundle installed and now I get this error:
Missing template jobs/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/home/ubuntu/workspace/app/views"
Sheesh.
Maciej Czuchnowski
36,441 PointsAre you using the haml-rails gem? https://rubygems.org/gems/haml-rails
Todd Squitieri
8,001 PointsYes, but I don't know where you got those gems from! I'm using THESE Haml-rails gems: https://rubygems.org/gems/haml
I went from Alpha to 4.0.6 to beta 1. None of these worked.
Why are we using different Haml gems than me???
Maciej Czuchnowski
36,441 PointsI always used the haml-rails gem because I assumed it will work better with Rails. Pure haml gem seems to be more general. Please try using the rails-haml instead of haml gem:
gem 'haml-rails', '~> 0.6.0'
and see if that helps. If not, you can show me your whole project (preferably Github) and maybe I will find what's wrong with it.
Todd Squitieri
8,001 PointsHi Maciej,
Appreciate your help. Unfortunately, I just tried it out and I still get the same error:
Missing template jobs/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/home/ubuntu/workspace/app/views"
Will post to Github and reply back to this thread in a little while. Thanks for following this!
Sincerely,
Todd