Sha256: e5bfbe59f62c47ffc466bfbb3482305965b90047e63bf641d3c400d135b5269b

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

class Admin::CommentsController < Admin::BaseController
  unloadable
  sortable_attributes :created_at, :name, :comment

  def index

    case
    when params[:article_id]
      @commentable = Article.find_by_id( params[:article_id] )
      @comments = @commentable.comments.paginate :page => params[:page], :order => sort_order
    else
      @comments = Comment.paginate :page => params[:page], :order => sort_order
    end

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @articles }
    end
  end

  def destroy
    @comment = Comment.find(params[:id])
    if spam_markable? and params[:spam]
      Viking.mark_as_spam({:signature => @comment.spam_signature})
    end
    @comment.destroy
    flash[:notice] = 'Comment was successfully deleted.'

    respond_to do |format|
      format.html { redirect_to( :back ) }
      format.xml  { head :ok }
    end
  end
  
protected
  
  def spam_markable?
    @spam_markable ||= defined?( Viking ) and Comment.new.respond_to?(:spam_signature)
  end
  helper_method :spam_markable?
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
beef-articles-0.5.3 app/controllers/admin/comments_controller.rb
beef-articles-0.5.2 app/controllers/admin/comments_controller.rb
beef-articles-0.5.1 app/controllers/admin/comments_controller.rb