wblog/app/controllers/admin/comments_controller.rb

24 lines
552 B
Ruby
Raw Normal View History

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
@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