问题描述
|
我在这里关注该教程: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,它仍然显示相同的错误。
解决方法
\“语法错误,意外的tASSOC,期待\')\'\”
您似乎在某处缺少右括号。在没有看到周围代码的情况下,我们可以做到最好。
编辑:“ \“周围的代码\”是指围绕surrounding4ѭ。
,我猜你错过了
views/posts/show.html.erb line no 20
中的\')\'。你能检查一下吗。