Move method 'recover_documents_from_cache' from documentable controllers to document.

This commit is contained in:
Senén Rodero Rodríguez
2017-09-23 22:16:18 +02:00
parent ce29185b76
commit c22637c349
6 changed files with 3 additions and 23 deletions

View File

@@ -21,6 +21,8 @@ class Document < ActiveRecord::Base
validates :documentable_id, presence: true, if: -> { persisted? }
validates :documentable_type, presence: true, if: -> { persisted? }
before_save :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? }
def set_cached_attachment_from_attachment(prefix)
self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem
attachment.path