Sha256: 763d400c02de65f09b9075b8371ed27168c7877b6e7e34c0a0f25badb956825c

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

require_dependency "spotlight/application_controller"

module Spotlight
  class AttachmentsController < ApplicationController
    before_filter :authenticate_user!
    before_filter do
      current_user.roles.include? :curator
    end

    before_action :set_attachment, only: [:show, :edit, :update, :destroy]

    # GET /attachments
    def index
      @attachments = Attachment.all
    end

    # GET /attachments/1
    def show
    end

    # GET /attachments/new
    def new
      @attachment = Attachment.new
    end

    # GET /attachments/1/edit
    def edit
    end

    # POST /attachments
    def create
      @attachment = Attachment.new(attachment_params)

 
      if @attachment.save
        render :json => @attachment
      else
        render action: 'new'
      end
    end

    # PATCH/PUT /attachments/1
    def update
      if @attachment.update(attachment_params)
        redirect_to @attachment, notice: 'Attachment was successfully updated.'
      else
        render action: 'edit'
      end
    end

    # DELETE /attachments/1
    def destroy
      @attachment.destroy
      redirect_to attachments_url, notice: 'Attachment was successfully destroyed.'
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_attachment
        @attachment = Attachment.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def attachment_params
        params.require(:attachment).permit(:name, :file, :uid)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-spotlight-0.0.3 app/controllers/spotlight/attachments_controller.rb
blacklight-spotlight-0.0.2 app/controllers/spotlight/attachments_controller.rb
blacklight-spotlight-0.0.1 app/controllers/spotlight/attachments_controller.rb