Help! Haml::SyntaxError in Posts#show

21 views
Skip to first unread message

Elysee Montissol

unread,
Mar 23, 2015, 12:04:44 AM3/23/15
to rubyonra...@googlegroups.com
Ok, so I'm challenging myself to actually learn ruby/rails, I'm
currently doing the 12 on 12 challenge by mackenzie childs, i'm doing
the Muze app. I'm trying to add a comment section to the post section of
the site but when i try to pull up a post, i'm getting:

Haml::SyntaxError in Posts#show
Extracted source (around line #10):

you can review the code below (i've marked it) line 10 is ".comment",
what is going on, whats wrong with that code? Please Help!!!!




= image_tag @post.image.url(:medium)
%h1= @post.title
%p= @post.description
%p= @post.user.name


#comment
%h2.comment_count= pluralize(@post.comments.count, "Comment")
- @comments.each do |comment|
(This is line 10) .comment
%p.username= comment.user.name
%p.username= comment.content

= render 'comments/form'


= link_to "Edit", edit_post_path(@post)
= link_to "Destroy", post_path(@post), method: :delete, data: [confirm:
"Are you sure?"]
= link_to "home", root_path

--
Posted via http://www.ruby-forum.com/.

Frederick Cheung

unread,
Mar 23, 2015, 4:13:04 AM3/23/15
to rubyonra...@googlegroups.com
On Monday, March 23, 2015 at 4:04:44 AM UTC, Ruby-Forum.com User wrote:
> Ok, so I'm challenging myself to actually learn ruby/rails, I'm
> currently doing the 12 on 12 challenge by mackenzie childs, i'm doing
> the Muze app. I'm trying to add a comment section to the post section of
> the site but when i try to pull up a post, i'm getting:
>
> Haml::SyntaxError in Posts#show
> Extracted source (around line #10):
>
> you can review the code below (i've marked it) line 10 is ".comment",
> what is going on, whats wrong with that code? Please Help!!!!
>


Since haml uses indentation to denote blocks etc it is very sensitive to indentation errors. I can't see if that's the cause of your problem though since your annotation has changed the indentation. There should also be more to the error message.

Fred.

Emmanuel Abia

unread,
Mar 23, 2015, 6:10:28 AM3/23/15
to rubyonra...@googlegroups.com

Try this...


%h2.comment_count= pluralize(@post.comments.count, "Comment")
>     - @comments.each do |comment|

          .comment
>           %p.username= comment.user.name
>           %p.username= comment.content
>
>      = render 'comments/form'

.comment seems to be a class selector move it to the correct place as well as your %p tags

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f3ec212a-fd47-4cd5-97b8-92eb97712994%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages