From e58feb7d6dd24bc7981e97fc9205fcbbe8ef516a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Sun, 24 Sep 2017 01:33:31 +0200 Subject: [PATCH] Fix for remote filesytem paperclip configuration. --- app/controllers/direct_uploads_controller.rb | 2 +- app/models/document.rb | 4 ++-- app/models/image.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/direct_uploads_controller.rb b/app/controllers/direct_uploads_controller.rb index 8fddf8b0c..3b0322356 100644 --- a/app/controllers/direct_uploads_controller.rb +++ b/app/controllers/direct_uploads_controller.rb @@ -13,7 +13,7 @@ class DirectUploadsController < ApplicationController if @direct_upload.valid? @direct_upload.save_attachment - @direct_upload.relation.set_cached_attachment_from_attachment(URI(request.url)) + @direct_upload.relation.set_cached_attachment_from_attachment render json: { cached_attachment: @direct_upload.relation.cached_attachment, filename: @direct_upload.relation.attachment.original_filename, diff --git a/app/models/document.rb b/app/models/document.rb index dca289c1e..f680bc04e 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -24,11 +24,11 @@ class Document < ActiveRecord::Base before_save :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? } after_save :remove_cached_attachment, if: -> { cached_attachment.present? } - def set_cached_attachment_from_attachment(prefix) + def set_cached_attachment_from_attachment self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem attachment.path else - prefix + attachment.url + attachment.url end end diff --git a/app/models/image.rb b/app/models/image.rb index 9c04336ec..84b38dd4a 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -32,11 +32,11 @@ class Image < ActiveRecord::Base before_save :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? } after_save :remove_cached_attachment, if: -> { cached_attachment.present? } - def set_cached_attachment_from_attachment(prefix) + def set_cached_attachment_from_attachment self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem attachment.path else - prefix + attachment.url + attachment.url end end