Files
codeocean/app/controllers/code_ocean/files_controller.rb
Hauke Klement 9790afe1a4 fix
2015-02-09 16:29:51 +01:00

29 lines
730 B
Ruby

module CodeOcean
class FilesController < ApplicationController
include CommonBehavior
include FileParameters
def authorize!
authorize(@file)
end
private :authorize!
def create
@file = CodeOcean::File.new(file_params)
authorize!
create_and_respond(object: @file, path: Proc.new { implement_exercise_path(@file.context.exercise, tab: 2) })
end
def destroy
@file = CodeOcean::File.find(params[:id])
authorize!
destroy_and_respond(object: @file, path: @file.context)
end
def file_params
params[:code_ocean_file].permit(file_attributes).merge(context_type: 'Submission', role: 'user_defined_file')
end
private :file_params
end
end