Don't allow to modify answer's images for started polls
Note that the `create` action doesn't create an image but updates an answer instead. We're removing the references to `:create` in the abilities since it isn't used. In the future we might change the form to add an image to an answer because it's been broken for ages since it shows all the attached images.
This commit is contained in:
committed by
Javi Martín
parent
5fe86264ca
commit
245594f32b
@@ -2,6 +2,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
include ImageAttributes
|
||||
|
||||
load_and_authorize_resource :answer, class: "::Poll::Question::Answer"
|
||||
load_and_authorize_resource only: [:destroy]
|
||||
|
||||
def index
|
||||
end
|
||||
@@ -11,6 +12,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
|
||||
def create
|
||||
@answer.attributes = images_params
|
||||
authorize! :update, @answer
|
||||
|
||||
if @answer.save
|
||||
redirect_to admin_answer_images_path(@answer),
|
||||
@@ -21,7 +23,6 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
end
|
||||
|
||||
def destroy
|
||||
@image = ::Image.find(params[:id])
|
||||
@image.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
Reference in New Issue
Block a user