Sha256: 640765aa0b6a937e459f79caa429c216b3417cd0ae99ec408b944efa16246f33

Contents?: true

Size: 848 Bytes

Versions: 17

Compression:

Stored size: 848 Bytes

Contents

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
symphonia-3.2.4 app/controllers/symphonia/attachments_controller.rb
symphonia-3.2.3 app/controllers/symphonia/attachments_controller.rb
symphonia-3.2.2 app/controllers/symphonia/attachments_controller.rb
symphonia-3.2.1 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.5 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.4 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.3 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.2 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.1 app/controllers/symphonia/attachments_controller.rb
symphonia-3.1.0 app/controllers/symphonia/attachments_controller.rb
symphonia-3.0.3 app/controllers/symphonia/attachments_controller.rb
symphonia-3.0.2 app/controllers/symphonia/attachments_controller.rb
symphonia-2.2.1 app/controllers/symphonia/attachments_controller.rb
symphonia-3.0.1 app/controllers/symphonia/attachments_controller.rb
symphonia-3.0.0 app/controllers/symphonia/attachments_controller.rb
symphonia-2.1.8 app/controllers/symphonia/attachments_controller.rb
symphonia-2.1.7 app/controllers/symphonia/attachments_controller.rb