Sha256: ab5440a56657851420de495493f2c929e672a8626d1812cf6b71dccde314b9d0
Contents?: true
Size: 957 Bytes
Versions: 10
Compression:
Stored size: 957 Bytes
Contents
module Blogit class CommentsController < ApplicationController blogit_authenticate except: [:create] expose(:post) { Blogit::Post.find(params[:post_id]) } expose(:comments) { post.comments } expose(:comment) { case params[:action] when /create/ then comments.new(params[:comment]) when /destroy/ then comments.find(params[:id]) end } def create 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.destroy respond_to do |format| format.html { redirect_to(post, notice: "Successfully removed comment.") } format.js end end end end
Version data entries
10 entries across 10 versions & 1 rubygems