From 3ceb700ea2b85a827ae737c25a5e72f1a5914f42 Mon Sep 17 00:00:00 2001 From: alpaca-tc Date: Sat, 6 May 2017 04:32:14 +0900 Subject: [PATCH] Fixes unknown mime type (#2822) --- app/models/concerns/attachmentable.rb | 2 +- app/models/media_attachment.rb | 2 +- config/initializers/paperclip.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/attachmentable.rb b/app/models/concerns/attachmentable.rb index 995643ada5..90ce884634 100644 --- a/app/models/concerns/attachmentable.rb +++ b/app/models/concerns/attachmentable.rb @@ -15,7 +15,7 @@ module Attachmentable next if attachment.blank? extension = Paperclip::Interpolations.content_type_extension(attachment, :original) basename = Paperclip::Interpolations.basename(attachment, :original) - attachment.instance_write :file_name, [basename, extension].delete_if(&:empty?).join('.') + attachment.instance_write :file_name, [basename, extension].delete_if(&:blank?).join('.') end end end diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 1613346ff8..d18ebabd41 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -128,7 +128,7 @@ class MediaAttachment < ApplicationRecord self.type = VIDEO_MIME_TYPES.include?(file_content_type) ? :video : :image extension = appropriate_extension basename = Paperclip::Interpolations.basename(file, :original) - file.instance_write :file_name, [basename, extension].delete_if(&:empty?).join('.') + file.instance_write :file_name, [basename, extension].delete_if(&:blank?).join('.') end def set_meta diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index d0dd613d0b..740c1a953e 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -4,7 +4,7 @@ Paperclip.options[:read_timeout] = 60 Paperclip.interpolates :filename do |attachment, style| return attachment.original_filename if style == :original - [basename(attachment, style), extension(attachment, style)].delete_if(&:empty?).join('.') + [basename(attachment, style), extension(attachment, style)].delete_if(&:blank?).join('.') end if ENV['S3_ENABLED'] == 'true'