class Admin::QuotesController < Admin::AdminController before_action :set_section def index @quotes = Quote.published.order(id: :desc).paginate(page: params[:page], per_page: 20) end def pending @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 @quote.save! flash.notice = "Quote successfully accepted." redirect_to pending_admin_quotes_url end def destroy @quote = Quote.find(params[:id]) @quote.destroy! flash.notice = "Quote successfully rejected." redirect_to pending_admin_quotes_url end private def set_section @section = "quotes" end def quote_params params.require(:quote).permit(:content, :state, :notes, :submitter, :tag_list, :audio) end end