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