about summary refs log tree commit diff stats
path: root/app/controllers/admin
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/admin')
-rw-r--r--app/controllers/admin/comments_controller.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index bd255ad..ccde3e6 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb
@@ -2,7 +2,29 @@ class Admin::CommentsController < Admin::AdminController
2 before_action :set_section 2 before_action :set_section
3 3
4 def index 4 def index
5 @comments = Comment.order(updated_at: :desc).paginate(page: params[:page], per_page: 20) 5 @comments = Comment.where(status: :published).order(updated_at: :desc).paginate(page: params[:page], per_page: 20)
6 end
7
8 def pending
9 @comments = Comment.where(status: :pending).order(updated_at: :desc).paginate(page: params[:page], per_page: 20)
10 end
11
12 def accept
13 @comment = Comment.find(params[:id])
14 @comment.status = :published
15 @comment.save!
16
17 flash.notice = "Comment successfully published."
18 redirect_to pending_admin_comments_url
19 end
20
21 def reject
22 @comment = Comment.find(params[:id])
23 @comment.status = :rejected
24 @comment.save!
25
26 flash.notice = "Comment successfully rejected."
27 redirect_to pending_admin_comments_url
6 end 28 end
7 29
8 def destroy 30 def destroy