diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-12 17:44:38 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-12 17:44:38 -0400 |
commit | 17d660fd4b8516d6b446f7c41d7b076a29a242a1 (patch) | |
tree | 115e7f3c1a3aa5bdc29dfa6d0c994eb795c658f6 /app/controllers/admin | |
parent | 835af696703484208882a70cc5dd47c5838ecf58 (diff) | |
download | thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.tar.gz thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.tar.bz2 thoughts-17d660fd4b8516d6b446f7c41d7b076a29a242a1.zip |
Added comment deleting
Also I seem to have fixed the JS errors that were preventing the fancy stuff in the admin panel from working.
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/comments_controller.rb | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ | |||
1 | class Admin::CommentsController < Admin::AdminController | ||
2 | before_action :set_section | ||
3 | |||
4 | def index | ||
5 | @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) | ||
6 | end | ||
7 | |||
8 | def destroy | ||
9 | if Comment.destroy(params[:id]) | ||
10 | flash.notice = "Comment successfully deleted." | ||
11 | else | ||
12 | flash.alert = "Could not delete comment." | ||
13 | end | ||
14 | |||
15 | redirect_to admin_comments_url | ||
16 | end | ||
17 | |||
18 | private | ||
19 | |||
20 | def set_section | ||
21 | @section = "comments" | ||
22 | end | ||
23 | end | ||