Sha256: 4e4edb97b9afcf32e20657a5b9d65843bc2a73f4108bc145aa14bc0f4136afee

Contents?: true

Size: 880 Bytes

Versions: 24

Compression:

Stored size: 880 Bytes

Contents

require_dependency "brightcontent/application_controller"

module Brightcontent
  class AttachmentsController < ApplicationController
    def show
      @attachments = Attachment.for_attachable(params[:type], params[:id])
      render layout: false
    end

    def create
      @attachment = Attachment.new(attachment_params)
      if @attachment.save
        render json: @attachment.to_json, status: :created
      else
        render json: @attachment.errors, status: :unprocessable_entity
      end
    end

    def destroy
      Attachment.destroy params[:id]
      head :no_content
    end

    def reposition
      Attachment.for_attachable(params[:type], params[:id]).reposition! params[:positions]
      head :no_content
    end

    private

    def attachment_params
      params.require(:attachment).permit(:attachable_id, :attachable_type, :asset)
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
brightcontent-attachments-2.6.0 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.5.1 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.5.0 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.6 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.5 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.4 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.3 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.2 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.1 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.4.0 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.3.4 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.3.3 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.3.2 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.3.1 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.3.0 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.2.2 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.2.1 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.2.0 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.1.5 app/controllers/brightcontent/attachments_controller.rb
brightcontent-attachments-2.1.4 app/controllers/brightcontent/attachments_controller.rb