按照Rails Guides实现一个博客系统http://guides.ruby.tw/rails3/getting_started.html
问题是:”删除评论”模块,点击”Destroy”超链接错误:
Unknown actionThe action 'show' could not be found for CommentsController
CommentsController.rb:::
class CommentsController < ApplicationController def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(params[:comment]) redirect_to post_path(@post) end def destroy @post = Post.find(params[:post_id]) @comment = @post.comments.find(params[:id]) @comment.destroy redirect_to post_path(@post) end end
原文地址:<Rails Guides>里 Destroy Comments 的问题, 感谢原作者分享。 其实只要你愿意,一切都可以变得很容易。