500 内部服务器错误

发布于 2024-11-09 12:00:38 字数 2980 浏览 0 评论 0原文

我在这里关注教程:http://guides.rubyonrails.org/getting_started.html

一切都工作正常,直到我尝试“8.1 渲染部分集合”,我开始收到此错误消息:

500 内部服务器错误

如果您是该网站的管理员 网站,那么请阅读此网页 应用程序的日志文件和/或网络 服务器的日志文件以查找内容 出错了。

在开发日志文件中我有:

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>

出了什么问题?

请帮忙。

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

编辑2:

这是views/comments/_comment.html.erb

<p>
  <b>Commenter:</b>
  <%= comment.commenter %>
</p>
 
<p>
  <b>Comment:</b>
  <%= comment.body %>
</p>

如果我删除以下应用程序运行:

<%= render :partial => "comments/comment",
           :collection => @post.comments %>

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猛虎独行 2024-11-16 12:00:38

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

您似乎在某处缺少右括号。在不查看周围代码的情况下,这是我们能做的最好的事情。

编辑:“周围代码”我的意思是周围views/posts/show.html.erb:20

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

听,心雨的声音 2024-11-16 12:00:38

我猜你错过了 views/posts/show.html.erb 第 20 行 中的“)”。你能检查一下吗?

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

[浮城] 2024-11-16 12:00:38

当 Rails 中出现错误中的错误时,您会收到该消息。 此答案更详细地说明了发生这种情况的原因以及如何解决此问题。

You get that message when you have an error within an error in Rails. This answer has greater context about why this happens and how you may troubleshoot this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文