Do not validate the attachment file content type ...

when the attachment has not changed
This commit is contained in:
Senén Rodero Rodríguez
2023-10-09 17:50:20 +02:00
parent 5f29680186
commit 2ae3045a04
2 changed files with 45 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ module Attachable
presence: true,
file_content_type: {
allow: ->(record) { record.accepted_content_types },
if: -> { association_class && attachment.attached? },
if: -> { association_class && attachment.attached? && attachment.new_record? },
message: ->(record, *) do
I18n.t("#{record.model_name.plural}.errors.messages.wrong_content_type",
content_type: record.attachment_content_type,