diff --git a/app/models/concerns/attachable.rb b/app/models/concerns/attachable.rb index 1fbe15512..8aec7ec65 100644 --- a/app/models/concerns/attachable.rb +++ b/app/models/concerns/attachable.rb @@ -26,7 +26,7 @@ module Attachable end def set_cached_attachment_from_attachment - self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem + self.cached_attachment = if filesystem_storage? attachment.path else attachment.url @@ -34,7 +34,7 @@ module Attachable end def set_attachment_from_cached_attachment - if Paperclip::Attachment.default_options[:storage] == :filesystem + if filesystem_storage? File.open(cached_attachment) { |file| self.attachment = file } else self.attachment = URI.open(cached_attachment) @@ -51,6 +51,10 @@ module Attachable private + def filesystem_storage? + Paperclip::Attachment.default_options[:storage] == :filesystem + end + def validate_attachment_size if association_class && attachment_file_size > max_file_size.megabytes errors.add(:attachment, I18n.t("#{model_name.plural}.errors.messages.in_between",