Sha256: af1596565c36ead18f58f3d6882882e4c7a2d974bae09f181a12041e37b973a8

Contents?: true

Size: 930 Bytes

Versions: 15

Compression:

Stored size: 930 Bytes

Contents

module Blogit
  class CommentsController < ApplicationController

    blogit_authenticate except: [:create]
    
    blogit_sweeper(:create, :update, :destroy)


    def create
      @comment = post.comments.new(params[:comment])
      respond_to do |format|
        format.js {
          # the rest is dealt with in the view
          @comment.save
        }

        format.html { 
          if @comment.save 
            redirect_to(post, notice: "Successfully added comment!")
          else
            render "blogit/posts/show"
          end
        }

      end

    end

    def destroy
      @comment = post.comments.find(params[:id])
      @comment.destroy
      respond_to do |format|
        format.html { redirect_to(post, notice: "Successfully removed comment.") }        
        format.js
      end
    end
    
    private

    def post
      @post ||= Blogit::Post.find(params[:post_id])
    end
    
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blogit-0.4.8 app/controllers/blogit/comments_controller.rb
blogit-0.4.7 app/controllers/blogit/comments_controller.rb
blogit-0.4.6 app/controllers/blogit/comments_controller.rb
blogit-0.4.5 app/controllers/blogit/comments_controller.rb
blogit-0.4.4 app/controllers/blogit/comments_controller.rb
blogit-0.4.3 app/controllers/blogit/comments_controller.rb
blogit-0.4.2 app/controllers/blogit/comments_controller.rb
blogit-0.4.1 app/controllers/blogit/comments_controller.rb
blogit-0.4.0 app/controllers/blogit/comments_controller.rb
blogit-0.3.2 app/controllers/blogit/comments_controller.rb
blogit-0.3.1 app/controllers/blogit/comments_controller.rb
blogit-0.3.0 app/controllers/blogit/comments_controller.rb
blogit-0.2.1 app/controllers/blogit/comments_controller.rb
blogit-0.2.0 app/controllers/blogit/comments_controller.rb
blogit-0.1.0 app/controllers/blogit/comments_controller.rb