我一直在尝试删除作为可评论宝石创建的评论。
我的代码:
<%= link_to "×", comment_delete_place_path(comment.id), :method => :delete, :remote => true, :confirm => "Are you sure you want to remove this comment?", :disable_with => "×", :class => 'close' %>
控制器 :
def comment_destroy
if params[:comment]
@comment = Comment.find(params[:id])
if @comment.destroy
respond_to do |format|
format.html { redirect_to @place, notice: 'The comment was successfully deleted!'}
format.js
end
end
end
end
路线:
delete 'places/comment/:id' => 'places#comment_destroy', as: 'comment_delete_place'
它没有给我任何错误,但它不会删除评论。我哪里错了?