qiaoyu's Blog

Rails101/8-3额外作业【实作删除】功能

8-3额外作业怎么解?

做8-3额外作业时,模仿4-5 https://fullstack.xinshengdaxue.com/posts/65 做【实作删除】功能。原文如下:

在app/controllers/groups_controller.rb里加入:

  • def destroy
  • @group = Group.find(params[:id])
  • @group.destroy
  • flash[:alert] = "Group deleted"
  • redirect_to groups_path
  • end

实际操作时要改成————
在app/controllers/posts_controller.rb里加入:

  • def destroy
  • @group = Post.find(params[:id])
  • @group.destroy
  • flash[:alert] = "Post deleted"
  • redirect_to groups_path
  • end

Comments

comments powered by Disqus