From 028562a049f6b5738731be9bedb2b2d9da1b575d Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 21 Feb 2018 16:09:30 +0000 Subject: Fix 500 error when loading an invalid upload URL --- app/uploaders/gitlab_uploader.rb | 4 ++++ app/uploaders/personal_file_uploader.rb | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'app/uploaders') diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb index a9e5c028b03..010100f2da1 100644 --- a/app/uploaders/gitlab_uploader.rb +++ b/app/uploaders/gitlab_uploader.rb @@ -67,6 +67,10 @@ class GitlabUploader < CarrierWave::Uploader::Base super || file&.filename end + def model_valid? + !!model + end + private # Designed to be overridden by child uploaders that have a dynamic path diff --git a/app/uploaders/personal_file_uploader.rb b/app/uploaders/personal_file_uploader.rb index e7d9ecd3222..f2ad0badd53 100644 --- a/app/uploaders/personal_file_uploader.rb +++ b/app/uploaders/personal_file_uploader.rb @@ -14,6 +14,12 @@ class PersonalFileUploader < FileUploader File.join(model.class.to_s.underscore, model.id.to_s) end + # model_path_segment does not require a model to be passed, so we can always + # generate a path, even when there's no model. + def model_valid? + true + end + # Revert-Override def store_dir File.join(base_dir, dynamic_segment) -- cgit v1.2.1