emu*_*rad 5 ruby ruby-on-rails
我在这里按照教程:http://guides.rubyonrails.org/getting_started.html
一切都工作正常,直到我尝试"8.1渲染部分集合"我开始收到此错误消息:
500内部服务器错误
如果您是本网站的管理员,请阅读此Web应用程序的日志文件和/或Web服务器的日志文件,以了解出现了什么问题.
在开发日志文件中我有:
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>
Run Code Online (Sandbox Code Playgroud)
怎么了?
请帮忙.
编辑: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 %> |
Run Code Online (Sandbox Code Playgroud)
编辑2:
这是views/comments/_comment.html.erb
<p>
<b>Commenter:</b>
<%= comment.commenter %>
</p>
<p>
<b>Comment:</b>
<%= comment.body %>
</p>
Run Code Online (Sandbox Code Playgroud)
如果我删除以下应用程序运行:
<%= render :partial => "comments/comment",
:collection => @post.comments %>
Run Code Online (Sandbox Code Playgroud)
但是,如果我将_comment.html.erb的内容更改为blablabla,它仍会显示相同的错误.
“语法错误,意外的 tASSOC,需要 ')'”
您似乎在某处缺少右括号。在不查看周围代码的情况下,这是我们能做的最好的事情。
编辑:“周围代码”我的意思是周围views/posts/show.html.erb:20.