Guest User

Untitled

a guest
Jun 9th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. class CommentsController < ApplicationController
  2. def index
  3. @post = Post.find(params[:post_id]
  4. @comments = @post.comments
  5. end
  6.  
  7. def show
  8. @post = Post.find(params[:post_id]
  9. @comment = @post.comments.find(params[:id])
  10. end
  11.  
  12. def new
  13. @post = Post.find(params[:post_id]
  14. @comment = @post.comments.build
  15. end
  16.  
  17. def edit
  18. @post = Post.find(params[:post_id]
  19. @comment = Comment.find(params[:id])
  20. if @comment.update_attributes(paramas[:comment])
  21. redirect_to post_comment_url(@post,@comment)
  22. else
  23. render :action => "edit"
  24. end
  25. end
  26.  
  27. def destroy
  28. @post = Post.find(params[:post_id]
  29. @comment = Comment.find(params[:id]
  30. @comment.destroy
  31.  
  32. respond_to do |format|
  33. format.html { redirect_to post_comments_path(@post)}
  34. format.xml { head :ok }
  35. end
  36. end
  37.  
  38. end
Add Comment
Please, Sign In to add comment