我正在尝试创建一个显示模型所有注释的Feed.
_comments.html.erb
<% if @comments.any? %>
<ol>
<%= render partial: 'shared/comment_feed', collection: @comments %>
</ol>
<%= will_paginate @comments %>
<% else %>
<h2>Be the first one to comment on this episode!</h2>
<% end %>
Run Code Online (Sandbox Code Playgroud)
_comment_feed.html.erb
<li id="<%= comment.id %>">
<%= link_to gravatar_for(comment.user), comment.user %>
<span class="user">
<%= link_to comment.user.name, comment.user %>
</span>
<span class="content"><%= simple_format comment.content %></span>
<span class="timestamp">
Posted <%= time_ago_in_words(comment.created_at) %> ago.
</span>
<% if current_user?(comment.user) %>
<%= link_to "delete", comment, method: :delete,
confirm: "Are you sure?",
title: comment.content %>
<% end %>
</li>
Run Code Online (Sandbox Code Playgroud)
上面的代码给了我一个未定义的局部变量或方法`comment'错误.当使用partial来呈现注释集合时,rails不会自动生成注释吗?任何帮助将不胜感激.
| 归档时间: |
|
| 查看次数: |
1382 次 |
| 最近记录: |