blob: 508c2a6221a4d2fe3e1b35025101d92ce77101fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class UploadsController < ApplicationController
def show
model = params[:model].camelize.constantize.find(params[:id])
uploader = model.send(params[:mounted_as])
return not_found! if model.respond_to?(:project) && !can?(current_user, :read_project, model.project)
return redirect_to uploader.url unless uploader.file_storage?
return not_found! unless uploader.file.exists?
disposition = uploader.image? ? 'inline' : 'attachment'
send_file uploader.file.path, disposition: disposition
end
end
|