diff --git a/app/models/concerns/attachable.rb b/app/models/concerns/attachable.rb index fb13dc517..1fbe15512 100644 --- a/app/models/concerns/attachable.rb +++ b/app/models/concerns/attachable.rb @@ -37,7 +37,7 @@ module Attachable if Paperclip::Attachment.default_options[:storage] == :filesystem File.open(cached_attachment) { |file| self.attachment = file } else - self.attachment = URI.parse(cached_attachment) + self.attachment = URI.open(cached_attachment) end end diff --git a/app/models/concerns/has_attachment.rb b/app/models/concerns/has_attachment.rb index 450e515ea..6f3f67844 100644 --- a/app/models/concerns/has_attachment.rb +++ b/app/models/concerns/has_attachment.rb @@ -9,7 +9,7 @@ module HasAttachment alias_method :"paperclip_#{attribute}=", :"#{attribute}=" define_method :"#{attribute}=" do |file| - if file.is_a?(IO) + if file.is_a?(IO) || file.is_a?(Tempfile) && !file.is_a?(Ckeditor::Http::QqFile) send(:"storage_#{attribute}").attach(io: file, filename: File.basename(file.path)) elsif file.nil? send(:"storage_#{attribute}").detach