Add document upload from admin section

This commit is contained in:
voodoorai2000
2018-11-29 12:30:47 +01:00
committed by decabeza
parent 9df433eeda
commit 19b7526421
13 changed files with 247 additions and 0 deletions

View File

@@ -24,6 +24,8 @@ class Document < ApplicationRecord
before_save :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? }
after_save :remove_cached_attachment, if: -> { cached_attachment.present? }
scope :admin, -> { where(admin: true) }
def set_cached_attachment_from_attachment
self.cached_attachment = if Paperclip::Attachment.default_options[:storage] == :filesystem
attachment.path