Sha256: 51df0d6cfcbb4adf7b1c7b0ebcc1c90ba65d0168317737ca81850fe3e40cc61d
Contents?: true
Size: 1.22 KB
Versions: 5
Compression:
Stored size: 1.22 KB
Contents
class Admin::CommentsController < Admin::BaseController before_filter :get_article def index list render_action 'list' end def list @comments = @article.comments.find(:all, :order => "id DESC") 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 :action => 'show', :id => @comment.id 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
5 entries across 5 versions & 1 rubygems