Sha256: 8e901c0a01fe5b39d69b73b2bfcba8eb72700f931bd03c910229ee9e5319c0a0
Contents?: true
Size: 891 Bytes
Versions: 2
Compression:
Stored size: 891 Bytes
Contents
# frozen_string_literal: true module Satis class AttachmentsController < ApplicationController before_action :set_objects def index @attachments = @model.public_send(@attachment_type) render json: @attachments end def create params[:attachments].each do |file| @model.public_send(@attachment_type).attach(file) end redirect_to request.referer || root_path, notice: "Attachment created successfully." end def destroy attachment = @model.public_send(@attachment_type).find_by(id: params[:id]) attachment&.purge redirect_to request.referer || root_path, notice: "Attachment deleted successfully." end private def set_objects @attachment_type = params[:attribute] || 'attachments' @model = GlobalID::Locator.locate_signed(params[:sgid], for: 'satis_attachments') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
satis-2.1.48 | app/controllers/satis/attachments_controller.rb |
satis-2.1.47 | app/controllers/satis/attachments_controller.rb |