【发布时间】:2015-03-03 13:40:15
【问题描述】:
我有一个嵌套资源,像这样的 cmets....
resources :microposts do
member do
get :upvote, :undo_upvote
end
member do
get :follow, :unfollow
end
resources :responses do
member do
get :upvote, :undo_upvote
end
resources :comments
end
end
我在 cmets 索引页上有一个删除按钮....
<div class = "Comment" id="comment-<%= comment.id %>">
<%= link_to comment_avatar_for(comment.user), comment.user %>
<span class="Commentator">
<%= comment.user.full_name %>
</span>
<span class="content">
<%= comment.body %>
</span>
<span class="timestamp">
Posted <%= time_ago_in_words(comment.created_at) %> ago.
</span>
<span class="timestamp">
<% if current_user?(comment.user) %>
<%= link_to "delete", comment, method: :delete, data: { confirm: "You sure?" }, :class => "btn btn-default btn-xs delete" %>
<% end %>
</span>
</div>
我在加载页面时收到此错误
undefined method `comment_path' for #<# <Class:0x007f8936876e70>:0x007f8931857020>
我不确定为什么这不起作用 - 毕竟我有正确的“评论”实例。如果有人能指出我正确的方向,我将不胜感激。
【问题讨论】:
标签: ruby-on-rails nested nested-resources