Errors in my haml file in a ruby on rails project

I'm following a tutorial to make a forum! when I wrote this code in the index.html.haml

- @posts.each do |post|
  %h2= post.title
%p 
Published at
= time_ago_in_words(post.created_at)
= link_to "New Post", new_post_path

I got this errors :

app/views/posts/index.html.haml:7: syntax error, unexpected keyword_ensure, expecting keyword_end app/views/posts/index.html.haml:10: syntax error, unexpected end-of-input, expecting keyword_end

I really need your help!

Answers


I think it may be an indentation problem. Try this:

- @posts.each do |post|
  %h2= post.title
  %p 
    Published at
    = time_ago_in_words(post.created_at)
= link_to "New Post", new_post_path

Make sure you have typed "end" at the end of your method and have another "end" that as the last line of code in your model.

Without seeing your code, it looks like your missing the "end" syntax somewhere.


Need Your Help

Error import cv2 : ImportError: numpy.core.multiarray failed to import

python opencv ubuntu numpy

I'm new to Ubuntu and I'm trying to use OpenCV module within Jupyter Notebook.

catch exception from included dll project

c# wpf visual-studio-2012

I have included a DLL project in my solution. From the main project I can normally debug, use breakpoints and so on. But if there is an exception I only get the information in the console and the