adds images to anwers

This commit is contained in:
rgarcia
2017-10-04 21:42:57 +02:00
parent 24fc7ab70a
commit 1cf9bc4ad1
10 changed files with 166 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseController
before_action :load_answer
def index
end
def new
@answer = ::Poll::Question::Answer.find(params[:answer_id])
end
def create
@answer = ::Poll::Question::Answer.find(params[:answer_id])
@answer.attributes = images_params
if @answer.save
redirect_to admin_answer_images_path(@answer),
notice: "Image uploaded successfully"
else
render :new
end
end
private
def images_params
params.require(:poll_question_answer)
.permit(images_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end
def load_answer
@answer = ::Poll::Question::Answer.find(params[:answer_id])
end
end