Ruby-on-rails 500内部服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6123665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:14:40  来源:igfitidea点击:

500 Internal Server Error

ruby-on-railsruby

提问by emurad

I'm following the tutorial here: http://guides.rubyonrails.org/getting_started.html

我正在关注这里的教程: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:

一切正常,直到我尝试“8.1 Rendering Partial Collections”我开始收到此错误消息:

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.

500内部服务器错误

如果您是此网站的管理员,请阅读此 Web 应用程序的日志文件和/或 Web 服务器的日志文件以找出问题所在。

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:

编辑: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:

编辑2:

Here's views/comments/_comment.html.erb

这是 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.

但是,如果我将 _comment.html.erb 的内容更改为 blablabla 它仍然显示相同的错误。

采纳答案by verdesmarald

"syntax error, unexpected tASSOC, expecting ')'"

“语法错误,意外的 tASSOC,期待 ')'”

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.

编辑:“周围代码”是指围绕views/posts/show.html.erb:20.

回答by Senthil Kumar Bhaskaran

I guess u have missed ')' in views/posts/show.html.erb line no 20. can you please check that one.

我猜你错过了 ')' views/posts/show.html.erb line no 20。你能检查一下吗?