diff --git a/app/helpers/documents_helper.rb b/app/helpers/documents_helper.rb index cf80b0261..17d70068b 100644 --- a/app/helpers/documents_helper.rb +++ b/app/helpers/documents_helper.rb @@ -8,16 +8,6 @@ module DocumentsHelper document.errors[:attachment].join(', ') if document.errors.key?(:attachment) end - def document_source_options - Hash[Document.sources.map { |k,v| [k, Document.human_attribute_name("document.#{k}")] }] - end - - def document_link_url(document) - uri = URI.parse(document.link) - return document.link if uri.scheme == "http" || uri.scheme == "https" - "http://#{document.link}" - end - def bytesToMeg(bytes) bytes / Numeric::MEGABYTE end diff --git a/app/models/document.rb b/app/models/document.rb index 8b6330f93..97789806f 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -7,12 +7,10 @@ class Document < ActiveRecord::Base belongs_to :user belongs_to :documentable, polymorphic: true - # validates_attachment :attachment, presence: true - validate :attachment_presence - # validates :attachment_prensence # Disable paperclip security validation due to polymorphic configuration # Paperclip do not allow to user Procs on valiations definition do_not_validate_attachment_file_type :attachment + validate :attachment_presence validate :validate_attachment_content_type, if: -> { attachment.present? } validate :validate_attachment_size, if: -> { attachment.present? } validates :title, presence: true