Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Sufia::UploadsControllerBehavior
- Loading branch information
Showing
2 changed files
with
19 additions
and
12 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/controllers/concerns/sufia/uploads_controller_behavior.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |