I’m following the tutorial here: http://guides.rubyonrails.org/getting_started.html
Everything was working fine until I tried “8.1 Rendering Partial Collections” I started getting this error message:
500 Internal Server Error
If you are the administrator of this
website, then please read this web
application’s log file and/or the web
server’s log file to find out what
went wrong.
In the development log file I have:
Started GET "/posts/3" for 127.0.0.1 at 2011-05-24 16:53:35 +0300
Processing by PostsController#show as HTML
Parameters: {"id"=>"3"}
[1m[36mPost Load (0.2ms)[0m [1mSELECT "posts".* FROM "posts" WHERE "posts"."id" = 3 LIMIT 1[0m
ERROR: compiling _app_views_posts_show_html_erb___599541849308356030_2168837280__3307996878912411319 RAISED /Users/username/Projects/blog/app/views/posts/show.html.erb:20: syntax error, unexpected tASSOC, expecting ')'
... :collection => @post.comments );@output_buf...
... ^
Function body: def _app_views_posts_show_html_erb___599541849308356030_2168837280__3307996878912411319(local_assigns)
_old_virtual_path, @_virtual_path = @_virtual_path, "posts/show";_old_output_buffer = @output_buffer;;@output_buffer = ActionView::OutputBuffer.new;@output_buffer.safe_concat('<p class="notice">');@output_buffer.append= ( notice );@output_buffer.safe_concat('</p>
<p>
<b>Name:</b>
');@output_buffer.append= ( @post.name );@output_buffer.safe_concat('
');@output_buffer.safe_concat('</p>
What’s wrong?
Please help.
EDIT: views/posts/show.html.erb:
<p class="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @post.name %>
</p>
<p>
<b>Title:</b>
<%= @post.title %>
</p>
<p>
<b>Content:</b>
<%= @post.content %>
</p>
<h2>Comments</h2>
<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
<%= render "comments/form" %>
<br />
<%= link_to 'Edit Post', edit_post_path(@post) %> |
<%= link_to 'Back to Posts', posts_path %> |
EDIT 2:
Here’s views/comments/_comment.html.erb
<p>
<b>Commenter:</b>
<%= comment.commenter %>
</p>
<p>
<b>Comment:</b>
<%= comment.body %>
</p>
If I remove the following the app runs:
<%= render :partial => "comments/comment",
:collection => @post.comments %>
However, if I change the content of _comment.html.erb to blablabla it still show the same error.
“syntax error, unexpected tASSOC, expecting ‘)'”
You appear to be missing a closing parenthesis somewhere. Without seeing the surrounding code that’s the best we can do.
Edit: by “surrounding code” I mean surrounding
views/posts/show.html.erb:20.