Allow Poll::Question::Answer edit

As requested by #1992
This commit is contained in:
Angel Perez
2017-10-06 09:48:17 -04:00
parent 806fd85246
commit 63eaa0bef6
13 changed files with 157 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
before_action :load_question
before_action :load_question, except: [:show, :edit, :update]
before_action :load_answer, only: [:show, :edit, :update]
load_and_authorize_resource :question, class: "::Poll::Question"
@@ -18,6 +19,21 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
end
end
def show
end
def edit
end
def update
if @answer.update(answer_params)
redirect_to admin_answer_path(@answer),
notice: t("flash.actions.save_changes.notice")
else
render :edit
end
end
private
def answer_params
@@ -27,4 +43,8 @@ class Admin::Poll::Questions::AnswersController < Admin::Poll::BaseController
def load_question
@question = ::Poll::Question.find(params[:question_id])
end
def load_answer
@answer = ::Poll::Question::Answer.find(params[:id])
end
end