Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 Internal Server Error

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.

like image 381
emurad Avatar asked May 25 '11 11:05

emurad


People also ask

Can you fix an internal server error?

Reload the web page. You can do that by selecting the refresh/reload button, pressing F5 or Ctrl+R, or trying the URL again from the address bar. Even if the 500 Internal Server Error is a problem on the webserver, the issue might be temporary. Trying the page again will often be successful.

How do I fix error 500 in Chrome?

If you are receiving an “Error 500 – Internal Server Error” message while trying to log into Canvas, you will need to clear the cookies on your web browser to resolve this issue.


1 Answers

"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.

like image 172
verdesmarald Avatar answered Oct 02 '22 14:10

verdesmarald