Extract documents action from Answer controller

This way we have a controller just to manage
Poll::Question::Answer related documents in the
same way we have for videos and images.
This commit is contained in:
taitus
2022-09-14 09:25:17 +02:00
parent cb2958e1b0
commit ec861ca8e6
7 changed files with 58 additions and 21 deletions

View File

@@ -0,0 +1,29 @@
class Admin::Poll::Questions::Answers::DocumentsController < Admin::Poll::BaseController
include DocumentAttributes
load_and_authorize_resource :answer, class: "::Poll::Question::Answer"
def index
end
def create
@answer.attributes = documents_params
if @answer.save
redirect_to admin_answer_documents_path(@answer),
notice: t("admin.documents.create.success_notice")
else
render :new
end
end
private
def documents_params
params.require(:poll_question_answer).permit(allowed_params)
end
def allowed_params
[documents_attributes: document_attributes]
end
end