2014-05-25 10:33:28 +08:00
|
|
|
class Admin::CommentsController < ApplicationController
|
|
|
|
layout 'layouts/admin'
|
|
|
|
before_action :authericate_user!
|
|
|
|
|
|
|
|
before_action do
|
|
|
|
@post = Post.find( params[:post_id] )
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
2014-05-25 23:08:48 +08:00
|
|
|
@comments = @post.comments.order(created_at: :desc)
|
2014-05-25 10:33:28 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
comment = @post.comments.find(params[:id])
|
|
|
|
if comment.destroy
|
|
|
|
flash[:notice] = '删除评论成功'
|
|
|
|
redirect_to admin_post_comments_path(@post)
|
|
|
|
else
|
|
|
|
flash[:alert] = '删除失败'
|
|
|
|
redirect_to admin_post_comments_path(@post)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|