trabajo-afectivo/app/controllers/knowledge_base/answer/attachments_controller.rb

27 lines
597 B
Ruby
Raw Normal View History

2019-06-04 03:40:48 +00:00
# Copyright (C) 2012-2017 Zammad Foundation, http://zammad-foundation.org/
class KnowledgeBase::Answer::AttachmentsController < ApplicationController
prepend_before_action :authentication_check
prepend_before_action { permission_check('knowledge_base.editor') }
before_action :fetch_answer
def create
@answer.add_attachment params[:file]
2019-06-04 03:40:48 +00:00
render json: @answer.assets({})
2019-06-04 03:40:48 +00:00
end
def destroy
@answer.remove_attachment params[:id]
2019-06-04 03:40:48 +00:00
render json: @answer.assets({})
2019-06-04 03:40:48 +00:00
end
private
def fetch_answer
@answer = KnowledgeBase::Answer.find params[:answer_id]
end
end