Sha256: a9bb446761a654a8864320bbb54179a5ce14f2487ba116955ba3faa8cd64f68b

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

class Comfy::Admin::Blog::CommentsController < Comfy::Admin::Blog::BaseController

  before_action :load_blog
  before_action :load_comment, :only => [:destroy, :toggle_publish]

  def index
    @comments = if @post = @blog.posts.where(:id => params[:post_id]).first
      comfy_paginate(@post.comments)
    else
      comfy_paginate(@blog.comments)
    end
  end

  def destroy
    @comment.destroy
    flash[:success] = 'Comment deleted'
    redirect_to :action => :index
  end

  def toggle_publish
    @comment.update_attribute(:is_published, !@comment.is_published?)
  end

protected

  def load_comment
    @comment = @blog.comments.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    flash[:error] = 'Comment not found'
    redirect_to :action => :index
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comfy_blog-1.12.3 app/controllers/comfy/admin/blog/comments_controller.rb
comfy_blog-1.12.2 app/controllers/comfy/admin/blog/comments_controller.rb