Sha256: d5c4155164bf5ecac57efab9cf2084652aed5314e8d005537c9290879c7d39a5

Contents?: true

Size: 783 Bytes

Versions: 3

Compression:

Stored size: 783 Bytes

Contents

class Admin::Blog::CommentsController < 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
      @post.comments.page(params[:page])
    else
      @blog.comments.page(params[:page])
    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

3 entries across 3 versions & 1 rubygems

Version Path
comfy_blog-1.1.1 app/controllers/admin/blog/comments_controller.rb
comfy_blog-1.1.0 app/controllers/admin/blog/comments_controller.rb
comfy_blog-1.0.0 app/controllers/admin/blog/comments_controller.rb