From 20f2479b33bc548c4736cdc1ceffde6e3af3a31d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 22:52:41 -0400 Subject: Added quote editing --- app/controllers/admin/quotes_controller.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/controllers/admin/quotes_controller.rb') diff --git a/app/controllers/admin/quotes_controller.rb b/app/controllers/admin/quotes_controller.rb index 2c09627..70a541f 100644 --- a/app/controllers/admin/quotes_controller.rb +++ b/app/controllers/admin/quotes_controller.rb @@ -9,6 +9,22 @@ class Admin::QuotesController < Admin::AdminController @quotes = Quote.pending.order(id: :desc).paginate(page: params[:page], per_page: 20) end + def edit + @quote = Quote.find(params[:id]) + end + + def update + @quote = Quote.find(params[:id]) + + if @quote.update(quote_params) + flash[:notice] = "Quote was successfully updated." + else + flash[:error] = "Error updating quote." + end + + render :edit + end + def accept @quote = Quote.find(params[:id]) @quote.state = :published @@ -31,4 +47,8 @@ class Admin::QuotesController < Admin::AdminController def set_section @section = "quotes" end + + def quote_params + params.require(:quote).permit(:content, :state, :notes, :submitter, :tag_list) + end end -- cgit 1.4.1