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/quotes_controller.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/controllers/admin/quotes_controller.rb b/app/controllers/admin/quotes_controller.rb new file mode 100644 index 0000000..2c09627 --- /dev/null +++ b/app/controllers/admin/quotes_controller.rb
@@ -0,0 +1,34 @@
1class Admin::QuotesController < Admin::AdminController
2 before_action :set_section
3
4 def index
5 @quotes = Quote.published.order(id: :desc).paginate(page: params[:page], per_page: 20)
6 end
7
8 def pending
9 @quotes = Quote.pending.order(id: :desc).paginate(page: params[:page], per_page: 20)
10 end
11
12 def accept
13 @quote = Quote.find(params[:id])
14 @quote.state = :published
15 @quote.save!
16
17 flash.notice = "Quote successfully accepted."
18 redirect_to pending_admin_quotes_url
19 end
20
21 def destroy
22 @quote = Quote.find(params[:id])
23 @quote.destroy!
24
25 flash.notice = "Quote successfully rejected."
26 redirect_to pending_admin_quotes_url
27 end
28
29 private
30
31 def set_section
32 @section = "quotes"
33 end
34end