gpt4 book ai didi

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

转载 作者:数据小太阳 更新时间:2023-10-29 07:17:19 26 4
gpt4 key购买 nike

我正在按照此处的教程进行操作:http://guides.rubyonrails.org/getting_started.html

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

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.

在我的开发日志文件中:

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,它仍然显示相同的错误。

最佳答案

“语法错误,意外的 tASSOC,需要 ')'”

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

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

关于ruby-on-rails - 500内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6123665/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com