From 17d660fd4b8516d6b446f7c41d7b076a29a242a1 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 12 Oct 2023 17:44:38 -0400 Subject: Added comment deleting Also I seem to have fixed the JS errors that were preventing the fancy stuff in the admin panel from working. --- app/controllers/admin/comments_controller.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 app/controllers/admin/comments_controller.rb (limited to 'app/controllers') diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb new file mode 100644 index 0000000..bd255ad --- /dev/null +++ b/app/controllers/admin/comments_controller.rb @@ -0,0 +1,23 @@ +class Admin::CommentsController < Admin::AdminController + before_action :set_section + + def index + @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) + end + + def destroy + if Comment.destroy(params[:id]) + flash.notice = "Comment successfully deleted." + else + flash.alert = "Could not delete comment." + end + + redirect_to admin_comments_url + end + + private + + def set_section + @section = "comments" + end +end -- cgit 1.4.1