Sha256: 6cd18e4b37d912f7af1e5a992b72965bad3d72b7ff6650935533970dfbfc9d8d
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
class Admin::CommentsController < Admin::BaseController before_filter :get_article def list index render :action => 'index' end def index @comments = @article.comments.find(:all, :order => "id ASC") end def show @comment = @article.comments.find(params[:id]) end def new @comment = @article.comments.build(params[:comment]) if request.post? and @comment.save # We should probably wave a spam filter over this, but for now, just mark it as published. @comment.mark_as_ham! flash[:notice] = 'Comment was successfully created.' redirect_to :controller => '/admin/comments', :article_id => @article.id, :action => 'list' end end def edit @comment = @article.comments.find(params[:id]) @comment.attributes = params[:comment] if request.post? and @comment.save flash[:notice] = 'Comment was successfully updated.' redirect_to :action => 'show', :id => @comment.id end end def destroy @comment = @article.comments.find(params[:id]) if request.post? @comment.destroy redirect_to :action => 'list' end end private def get_article @article = Article.find(params[:article_id]) if @article.nil? redirect_to '/admin' end end end
Version data entries
6 entries across 6 versions & 1 rubygems