Skip to content

Commit

Permalink
Use Sufia::UploadsControllerBehavior
Browse files Browse the repository at this point in the history
  • Loading branch information
awead committed Jun 13, 2016
1 parent 51090b3 commit 0f035cc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
18 changes: 18 additions & 0 deletions app/controllers/concerns/sufia/uploads_controller_behavior.rb
@@ -0,0 +1,18 @@
module Sufia::UploadsControllerBehavior
extend ActiveSupport::Concern

included do
load_and_authorize_resource class: UploadedFile
end

def create
@upload.attributes = { file: params[:files].first,
user: current_user }
@upload.save!
end

def destroy
@upload.destroy
head :no_content
end
end
13 changes: 1 addition & 12 deletions app/controllers/sufia/uploads_controller.rb
@@ -1,16 +1,5 @@
module Sufia
class UploadsController < ApplicationController
load_and_authorize_resource class: UploadedFile

def create
@upload.attributes = { file: params[:files].first,
user: current_user }
@upload.save!
end

def destroy
@upload.destroy
head :no_content
end
include Sufia::UploadsControllerBehavior
end
end

0 comments on commit 0f035cc

Please sign in to comment.