Merge branch 'rails5-fix-46276' into 'master'
Rails5 fix format in uploads actions Closes #46276 See merge request gitlab-org/gitlab-ce!19907
This commit is contained in:
commit
719e0dc39e
2 changed files with 18 additions and 0 deletions
|
@ -1,9 +1,15 @@
|
|||
module UploadsActions
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include Gitlab::Utils::StrongMemoize
|
||||
include SendFileUpload
|
||||
|
||||
UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze
|
||||
|
||||
included do
|
||||
prepend_before_action :set_html_format, only: :show
|
||||
end
|
||||
|
||||
def create
|
||||
link_to_file = UploadService.new(model, params[:file], uploader_class).execute
|
||||
|
||||
|
@ -41,6 +47,13 @@ module UploadsActions
|
|||
|
||||
private
|
||||
|
||||
# Explicitly set the format.
|
||||
# Otherwise rails 5 will set it from a file extension.
|
||||
# See https://github.com/rails/rails/commit/84e8accd6fb83031e4c27e44925d7596655285f7#diff-2b8f2fbb113b55ca8e16001c393da8f1
|
||||
def set_html_format
|
||||
request.format = :html
|
||||
end
|
||||
|
||||
def uploader_class
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
|
5
changelogs/unreleased/rails5-fix-46276.yml
Normal file
5
changelogs/unreleased/rails5-fix-46276.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Rails5 fix format in uploads actions
|
||||
merge_request: 19907
|
||||
author: Jasper Maes
|
||||
type: fixed
|
Loading…
Reference in a new issue