module Symphonia class AttachmentsController < ApplicationController before_action :require_login, :find_attachment def show # find_attachment render(plain: @attachment.attachment.url(:original), layout: false) end def destroy # find_attachment @attachment.destroy respond_to do |format| format.html do flash[:notice] = t(:"text_#{@attachment.type.underscore}_successfully_destroy") redirect_back_or_default(polymorphic_path(@attachment.attachable)) end format.js end end def reorder # find_attachment new_position = params.require(:position).to_i @attachment.insert_at(new_position) head :ok end private def find_attachment @attachment = Attachment.find(params.require(:id)) end end end