diff --git a/app/models/concerns/attachable.rb b/app/models/concerns/attachable.rb index cc457f934..87bd92363 100644 --- a/app/models/concerns/attachable.rb +++ b/app/models/concerns/attachable.rb @@ -5,9 +5,8 @@ module Attachable has_one_attached :attachment attr_accessor :cached_attachment - validate :attachment_presence - validates :attachment, + presence: true, file_content_type: { allow: ->(record) { record.accepted_content_types }, if: -> { association_class && attachment.attached? }, @@ -63,12 +62,4 @@ module Attachable def file_path ActiveStorage::Blob.service.path_for(attachment.blob.key) end - - private - - def attachment_presence - unless attachment.attached? - errors.add(:attachment, I18n.t("errors.messages.blank")) - end - end end