diff options
Diffstat (limited to 'app/controllers/admin/comments_controller.rb')
-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 | ||