Class: PeanutGallery::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PeanutGallery::CommentsController
- Defined in:
- app/controllers/peanut_gallery/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'app/controllers/peanut_gallery/comments_controller.rb', line 3 def create @comment = Comment.new(comment_params) if @comment.save redirect_to params[:peanut_gallery_comment][:redirect_route], :notice => 'Comment created!' else redirect_to params[:peanut_gallery_comment][:redirect_route], :notice => 'Comment could not be saved.' end end |
#destroy ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/peanut_gallery/comments_controller.rb', line 27 def destroy @comment = Comment.find_by_id(params[:id]) if @comment.nil? raise "Could not find comment." else @comment.destroy redirect_to request.referrer, :notice => 'Comment deleted!' end end |
#update ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/peanut_gallery/comments_controller.rb', line 14 def update @comment = Comment.find_by_id(params[:id]) if @comment.nil? raise "Could not find comment." else if @comment.save redirect_to request.referrer, :notice => 'Comment saved!' else redirect_to request.referrer, :notice => 'Comment could not be saved.' end end end |